Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalToIf/beforeIfPresentOrElse.java
Artemiy Sartakov 6f1efb8fc0 OptionalToIfInspection: added inspection to desugar optional chain to sequence of if statements (IDEA-212269)
GitOrigin-RevId: c83b70e05544529b3dfffe24bc87997910edcb56
2019-08-07 17:02:43 +03:00

16 lines
492 B
Java

// "Fix all 'Optional can be replaced with sequence of if statements' problems in file" "true"
class Test {
void inStatement(String in) {
Optional.ofNullable<caret>(in).filter(s -> s.length > 2).map(s -> s.substring(3)).map(ss -> getStrOrNull(ss))
.ifPresentOrElse(value -> System.out.println("found value %s", value),
() -> System.out.println("value is null"));
}
private String getStrOrNull(String s) {
return s.length() > 2 ? s : null;
}
}