Files
Andrey.Cherkasov 108dc80b56 [java-intentions] ConvertSwitchToIf: fix the intention according a switch throws NPE if the selector expression is null
IDEA-300120

GitOrigin-RevId: 5d77f98e7931e32a06cb3c54076978d317f78a98
2022-08-17 23:14:53 +00:00

16 lines
392 B
Java

import java.util.Objects;
// "Replace 'switch' with 'if'" "true-preview"
abstract class Test {
abstract Object getObject();
void foo(Object o) {
if (Objects.requireNonNull(o) instanceof String) {
System.out.println("one");
} else if (o instanceof Integer) {
System.out.println("two");
} else {
System.out.println("default");
}
}
}