I\'m trying to group Java objects by their field, i.e Person.java
public class Person {
String name;
String surname;
....
}
You can use Multimap and groupBy() from Eclipse Collections
MutableList allPeople = Lists.mutable.empty();
MutableListMultimap multimapByName = allPeople.groupBy(Person::getName);
If you can't change the type of allPeople from List
List allPeople = new ArrayList<>();
MutableListMultimap multimapByName =
ListAdapter.adapt(allPeople).groupBy(Person::getName);
Note: I am a contributor to Eclipse Collections.