You can do it with groupingBy
.
Assuming that your input is a List
, the Map
member inside the Dog
class is called map
, and the Breed is stored for the "Breed" key :
List dogs = ...
Map> map = dogs.stream()
.collect(Collectors.groupingBy(d -> d.map.get("Breed")));