Use switch expression where feasible

This commit is contained in:
Yanming Zhou
2023-11-01 10:49:43 +08:00
committed by Sam Brannen
parent 8ed04b5dd1
commit 490b5c77fc
28 changed files with 420 additions and 424 deletions

View File

@@ -184,14 +184,10 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
}
char ch = expressionString.charAt(pos);
switch (ch) {
case '{':
case '[':
case '(':
case '{', '[', '(' -> {
stack.push(new Bracket(ch, pos));
break;
case '}':
case ']':
case ')':
}
case '}', ']', ')' -> {
if (stack.isEmpty()) {
throw new ParseException(expressionString, pos, "Found closing '" + ch +
"' at position " + pos + " without an opening '" +
@@ -203,9 +199,8 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
"' at position " + pos + " but most recent opening is '" + p.bracket +
"' at position " + p.pos);
}
break;
case '\'':
case '"':
}
case '\'', '"' -> {
// jump to the end of the literal
int endLiteral = expressionString.indexOf(ch, pos + 1);
if (endLiteral == -1) {
@@ -213,7 +208,7 @@ public abstract class TemplateAwareExpressionParser implements ExpressionParser
"Found non terminating string literal starting at position " + pos);
}
pos = endLiteral;
break;
}
}
pos++;
}