From 572a321e7ef3a48d35ef7af2a813d266df359e5d Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 12 Sep 2024 09:36:55 -0400 Subject: [PATCH] Convert cascading if-else to switch --- src/test/java/org/apache/commons/jexl3/VarTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/apache/commons/jexl3/VarTest.java b/src/test/java/org/apache/commons/jexl3/VarTest.java index 9890975fc..e48ba483f 100644 --- a/src/test/java/org/apache/commons/jexl3/VarTest.java +++ b/src/test/java/org/apache/commons/jexl3/VarTest.java @@ -130,15 +130,15 @@ public Map get(final Map map) { * @return the string representation of year, month or day */ public String get(final String property) { - if ("yyyy".equals(property)) { + switch (property) { + case "yyyy": return Integer.toString(cal.get(Calendar.YEAR)); - } - if ("MM".equals(property)) { + case "MM": return Integer.toString(cal.get(Calendar.MONTH) + 1); - } - - if ("dd".equals(property)) { + case "dd": return Integer.toString(cal.get(Calendar.DAY_OF_MONTH)); + default: + break; } return null; }