I have a problem grouping two values with Java 8.
My main problem is about grouping two fields, I group correctly one field called getNameOfCountryOrRegion() but now I am interested in groupingBy another field that is called leagueDTO as well.
Map<String, List<FullCalendarDTO>> result = countryDTOList.stream()
.collect(Collectors.groupingBy(
FullCalendarDTO::getNameOfCountryOrRegion));
And the following class :
public class FullCalendarDTO {
private long id;
private TeamDTO localTeam;
private TeamDTO visitorTeam;
private LocationDTO location;
private String leagueDTO;
private String timeStamp;
private String nameOfCountryOrRegion;
}
The result will be grouped by nameOfCountryOrRegion and leagueDTO.
groupingBy()would have to build and return an appropriate object.groupingByboth the attributes. Possibly any other meaning as well?