in java-samples/src/main/java/com/jetbrains/code/jdk21/PatternMatchingForSwitch.java [53:63]
static void shouldSuggestMigratingMoreComplexExampleToPatternMatchingForSwitch(Object x) {
if (x instanceof String str && !str.isEmpty()) {
System.out.println(str);
} else if (x instanceof Integer integer && integer > 0) {
System.out.println(integer + 1);
} else if (x instanceof List<?> list && !list.isEmpty()) {
System.out.println(list.size());
} else {
throw new IllegalArgumentException("Unexpected type: " + x);
}
}