I want to extract a List
from a Map
(E
is a random Class) using stream()
.
I
You can use Collectors2.flatCollect from Eclipse Collections
List<String> list =
map.values().stream().collect(Collectors2.flatCollect(l -> l, ArrayList::new));
You can also adapt the Map
and use the Eclipse Collections MutableMap
API.
List<String> list =
Maps.adapt(map).asLazy().flatCollect(l -> l).toList();
The method flatCollect
is equivalent to the method flatMap
, except flatCollect
takes an Iterable
instead of a Stream
.
Note: I am a committer for Eclipse Collections.