How can we turn a List<Foo> towards a Map<propertyA, List<propertyB>> in the most optimal way by using java streams.
Beware: propertyA is NOT unique
//pseudo-code
class Foo
propertyA //not unique
List<propertyB>
So far I have the following:
fooList.stream()
.collect(Collectors.groupingBy(Foo::propertyA,
Collectors.mapping(Foo::propertyB, Collectors.toList())))
Resulting into a Map<propretyA, List<List<propretyB>>>
which is not yet flattened for its value.