I have a class A which has some fields.
Class A{
String type;
String x;
String y;
}
Class B{
String x;
String y;
}
Let's say we have a list List<A>
. By using Collectors.groupingBy()
, is it possible to get output Map<String,List<B>>
instead Map<String,List<A>>
? where key
in the Map
is type
field in Class A
.
Of course - just chain a
mapping()
collector to thegroupingBy()
collector.