Skip to content

Commit

Permalink
Convert cascading if-else to switch
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Sep 12, 2024
1 parent 502fa4c commit 572a321
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/test/java/org/apache/commons/jexl3/VarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ public Map<String,Object> get(final Map<String,String> 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;
}
Expand Down

0 comments on commit 572a321

Please sign in to comment.