Use switch expression where feasible
This commit is contained in:
committed by
Sam Brannen
parent
8ed04b5dd1
commit
490b5c77fc
@@ -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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user