I have a class -
public class LocationStats {
private String state;
private String country;
private int latestTotalCases;
private int diffFromPrevDay;
private int diffFromPrev2Day;
private int diffFromPrev3Day;
}
Top Sum-up total cases for a country I used below snippet, which is working fine.
List<LocationStats> newStats= getData();
Map<String, Integer> collect =
newStats
.stream()
.collect(Collectors.groupingBy(LocationStats::getCountry, Collectors.summingInt(LocationStats::getLatestTotalCases)));
I want to sum-up the other 3 attribues as well while processing the above-mentioned snippet. Is it possible ? Is there any Lambda-elegant way to achieve that ?