Replace if with switch where feasible
See gh-31916
This commit is contained in:
committed by
Stéphane Nicoll
parent
ea5ef098cf
commit
cfa3aa001f
@@ -1778,19 +1778,13 @@ class SpelReproTests extends AbstractExpressionTests {
|
||||
|
||||
@Override
|
||||
public Object resolve(EvaluationContext context, String beanName) throws AccessException {
|
||||
if (beanName.equals("foo")) {
|
||||
return "custard";
|
||||
}
|
||||
else if (beanName.equals("foo.bar")) {
|
||||
return "trouble";
|
||||
}
|
||||
else if (beanName.equals("&foo")) {
|
||||
return "foo factory";
|
||||
}
|
||||
else if (beanName.equals("goo")) {
|
||||
throw new AccessException("DONT ASK ME ABOUT GOO");
|
||||
}
|
||||
return null;
|
||||
return switch (beanName) {
|
||||
case "foo" -> "custard";
|
||||
case "foo.bar" -> "trouble";
|
||||
case "&foo" -> "foo factory";
|
||||
case "goo" -> throw new AccessException("DONT ASK ME ABOUT GOO");
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user