How could I do the following with Java Streams?
Let\'s say I have the following classes:
class Foo {
Bar b;
}
class Bar {
String id;
Str
You can group your data in one go assuming there are only distinct Foo:
Map> map = list.stream()
.collect(Collectors.groupingBy(f -> f.b.id,
Collectors.toMap(f -> f.b.date, Function.identity())));
Saving some characters by using static imports:
Map> map = list.stream()
.collect(groupingBy(f -> f.b.id, toMap(f -> f.b.date, identity())));