I want to create a Map
from a List
of Points
and have inside the map all entries from the list mapped with the same parentId such as
Collectors.groupingBy
is exactly what you want, it creates a Map from your input collection, creating an Entry using the Function
you provide for it's key, and a List of Points with your associated key as it's value.
Map> pointByParentId = chargePoints.stream()
.collect(Collectors.groupingBy(Point::getParentId));