I have a Map of Lists of Foo items (foos), and I want to transform each item in the sublists to a Bar, filter out bad Bars, transform to Baz and keep the results as a new list of Bazs
List<Baz> barList = foos.values() .stream() .flatMap(List::stream) .map(Foo::transformToBar) .filter(Bar::isBad) .map(Baz::transformToBaz) .collect(Collectors.toList());
I have a Map of Lists of Foo items (foos), and I want to transform each item in the sublists to a Bar, filter out bad Bars, transform to Baz and keep the results as a new list of Bazs
The syntax is a little clunky at times... but once you get used to it it's quite expressive.