mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 05:51:25 +07:00
[java-inspections] IDEA-358770 Stream/Optional desugaring: support Predicate.not
GitOrigin-RevId: af9cdb5e674406bbbe94a746e85a662a590a4d3d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
870a7cd709
commit
cf460af83e
@@ -1,6 +1,8 @@
|
||||
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
@@ -12,6 +14,16 @@ public class Main {
|
||||
String testTernary(String[] strings) {
|
||||
return Arrays.stream(strings).filter(Objects::nonNull).anyMatch(s -> !s.startsWith("xyz")) ? "s" : null;
|
||||
}
|
||||
|
||||
void predicateNot() {
|
||||
boolean res = Stream.of(Optional.of(1), Optional.of(2), Optional.empty())
|
||||
.anyMatch(Predicate.not(Optional::isEmpty));
|
||||
}
|
||||
|
||||
void predicateNotLambda() {
|
||||
boolean res = Stream.of(Optional.of(1), Optional.of(2), Optional.empty())
|
||||
.anyMatch(Predicate.not(o -> o.isEmpty()));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(test(asList(asList(), asList("a"), asList("b", "c"))));
|
||||
|
||||
Reference in New Issue
Block a user