Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/optionalIsPresent/afterTernaryFunction.java
Tagir Valeev 588d978362 OptionalIsPresentInspection: do not warn if map() part can be null
If we cannot determine the non-nullity of map expression, then info
level is used. Fixes IDEA-172609 "Replace Optional.isPresent() checks
with functional-style expressions" is broken.
2017-05-31 17:48:57 +07:00

13 lines
466 B
Java

// "Replace Optional.isPresent() condition with functional style expression" "INFORMATION"
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) {
// information level: could be semantic change if onPresent returns null
Object o = opt.map(onPresent::apply).orElseGet(onEmpty::get);
}
}