mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-02 03:07:47 +07:00
21 lines
666 B
Java
21 lines
666 B
Java
// "Replace Stream API chain with loop" "true"
|
|
|
|
import java.util.*;
|
|
|
|
public class Main {
|
|
|
|
private static long test(Map<String, List<String>> strings) {
|
|
return strings.entrySet().stream().filter(e -> !e.getKey().isEmpty())
|
|
.flatMap(entry -> entry.getValue().stream().filter(entry.getKey()::equals))
|
|
.c<caret>ount();
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
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));
|
|
}
|
|
} |