how to grouping and maxBy (list of maps)
1) list of maps :
2) grouping and maxBy
3) before and results
appendix) to copy
List<Optional<Map<String, Object>>> aggrList =
mockList.stream().collect(Collectors.groupingBy(p -> (String)p.get("niveau_1")+ (String)p.get("niveau_2")+(String)p.get("franchise"),
Collectors.maxBy(Comparator.comparingLong(p->Long.valueOf(p.get("cnt").toString())))))
.values().stream().collect(Collectors.toList());
List<Map<String, Object>> endList= new ArrayList<>();
aggrList.stream().forEach(s->{
endList.add(s.get());
});
System.out.println("result list");
endList.stream().forEach(System.out::println);