mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
28 lines
930 B
Java
28 lines
930 B
Java
// "Replace Stream API chain with loop" "true"
|
|
|
|
import java.util.*;
|
|
import java.util.function.Predicate;
|
|
import java.util.stream.Stream;
|
|
|
|
public class Main {
|
|
|
|
private static long test(Map<String, List<String>> strings) {
|
|
return strings.entrySet().stream().filter(s -> !s.getKey().isEmpty()).mapToLong(e -> e.getValue().stream().filter(new Predicate<String>() {
|
|
// we're inside anonymous class
|
|
@Override
|
|
public boolean test(String s) {
|
|
return e.getKey().equals(s);
|
|
}
|
|
}).count()).s<caret>um();
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
boolean x = Stream.of(1, 2, 3).anyMatch(Objects::nonNull);
|
|
Map<String, List<String>> map = new HashMap<>();
|
|
map.put("", Arrays.asList("", "a", "b"));
|
|
map.put("a", Arrays.asList("", "a", "b", "a"));
|
|
map.put("b", Arrays.asList("", "a", "b"));
|
|
map.put("c", Arrays.asList("", "a", "b"));
|
|
System.out.println(test(map));
|
|
}
|
|
} |