Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalIsPresent/afterTernaryFunctionNull.java
Tagir Valeev f1bc1f9819 OptionalIsPresentInspection: warn if map(x -> nullable).orElse(null)
In this case semantics preserved if map expression returns null.
2017-12-27 15:40:02 +07:00

13 lines
433 B
Java

// "Replace Optional.isPresent() condition with functional style expression" "GENERIC_ERROR_OR_WARNING"
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
public class Main {
public void test(Optional<String> opt, Function<String, Object> onPresent, Supplier<Object> onEmpty) {
// warning level: no semantics change
Object o = opt.map(onPresent::apply).orElse(null);
}
}