Suppose I have a class as
Class Person {
String name;
String uid;
String phone;
}
I am trying to group by all the fields of the class. How do i use parallel streams in JAVA 8 to convert a
List<Person> into Map<String,Set<Person>>
where the key of the map is the value of each field in the class . JAVA 8 the following example groups by a single field, how can i do it for all fields of a class into a single Map?
ConcurrentMap<Person.Sex, List<Person>> byGender =
roster
.parallelStream()
.collect(
Collectors.groupingByConcurrent(Person::getGender));