I need to count occurences of some special bundles.
Map<Integer,Integer> countBundles(){
return bundles.stream()
.bla()
.bla()
.bla()
.collect(groupingBy(Bundle::getId), counting()));
}
This code does not compile because counting returns Long. Is there any beautiful way to return Map<Integer, Integer>?
I have this idea, but it`s ugly
map.entrySet().stream()
.collect(toMap(Map.Entry::getKey, entry -> (int) entry.getValue().longValue()));