I'd like group by a field a select
Guess this class:
public class Person {
private Name name;
private Address address;
...
}
public class Name {
private String name;
private String fatherName;
private String motherName;
}
I'd like to group by Person.getName().getMotherName()
and select Person.getName()
as grouping object key.
Collection<Person> persons = new ...
Map<Name, List<Person>> group = persons.stream()
.collect(groupingby(p -> p.getName().getMotherName());
As you can see, I'd like to get a Map<Name, List<Person>>
, instead of a Map<String, List<Person>>
Any ideas?