mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-23 15:03:36 +07:00
34 lines
1.0 KiB
Java
34 lines
1.0 KiB
Java
import java.util.*;
|
|
import java.util.stream.*;
|
|
|
|
// IDEA-200094
|
|
class Main {
|
|
void flatMapAlwaysNull(List<String> input) {
|
|
List<String> side = new ArrayList<>();
|
|
long count = input.stream().<String>flatMap(e -> {
|
|
if(!e.isEmpty()) side.add(e);
|
|
return null;
|
|
}).count();
|
|
if (side.isEmpty()) {} // not known
|
|
if (<warning descr="Condition 'count > 0' is always 'false'">count > 0</warning>) {}
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
new Main().myMethod();
|
|
}
|
|
|
|
private void myMethod() {
|
|
List<Integer> numberOne = Collections.singletonList(1);
|
|
List<Integer> collectionBeingModifiedSometimes = new ArrayList<>();
|
|
|
|
List<Integer> numberTwo = numberOne.stream().flatMap(entry -> {
|
|
if (Math.random() > 0.5) {
|
|
collectionBeingModifiedSometimes.add(999);
|
|
}
|
|
return Stream.of(entry * 2);
|
|
}).collect(Collectors.toList());
|
|
|
|
String text = collectionBeingModifiedSometimes.size() == 0 ? "empty" : "nonempty";
|
|
System.out.println("" + numberOne + " " + numberTwo + " " + text);
|
|
}
|
|
} |