mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-11 20:07:01 +07:00
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.
16 lines
524 B
Java
16 lines
524 B
Java
// "Replace Optional.isPresent() condition with functional style expression" "GENERIC_ERROR_OR_WARNING"
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
|
|
public class Main {
|
|
private static String test(List<Object> list) {
|
|
Optional<Object> first = list.stream().filter(obj -> obj instanceof String).findFirst();
|
|
return (String) first.orElse(null);
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
System.out.println(test(Arrays.asList(null, null, "aa", "bbb", "c", null, "dd")));
|
|
}
|
|
} |