You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/09/12 13:37:15 UTC

(commons-jexl) 12/17: Convert cascading if-else to switch

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git

commit ae74c98ff60b881480cf32d2cd7b69e7c6a74adc
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 09:36:13 2024 -0400

    Convert cascading if-else to switch
---
 src/test/java/org/apache/commons/jexl3/JexlTest.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/JexlTest.java b/src/test/java/org/apache/commons/jexl3/JexlTest.java
index 33d3e501..5e95e576 100644
--- a/src/test/java/org/apache/commons/jexl3/JexlTest.java
+++ b/src/test/java/org/apache/commons/jexl3/JexlTest.java
@@ -49,14 +49,15 @@ public final class JexlTest extends JexlTestCase {
 
         @SuppressWarnings("boxing")
         public Integer get(final String val) {
-            if ("zero".equals(val)) {
+            switch (val) {
+            case "zero":
                 return 0;
-            }
-            if ("one".equals(val)) {
+            case "one":
                 return 1;
-            }
-            if ("user".equals(val)) {
+            case "user":
                 return user;
+            default:
+                break;
             }
             return -1;
         }