mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-29 08:20:55 +07:00
14 lines
490 B
Java
14 lines
490 B
Java
// "Collapse loop with stream 'collect()'" "true-preview"
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class Main {
|
|
List<String> test(Map<String, List<String>> map, int limit) {
|
|
List<String> list = map.entrySet().stream().filter(entry -> entry.getValue() != null).flatMap(entry -> entry.getValue().stream()).filter(str -> str.contains("foo")).limit(limit).collect(Collectors.toList());
|
|
return list;
|
|
}
|
|
}
|