Map<Integer, List<Entity>> groupBy = entityList.stream() .collect(Collectors.groupingBy(Entity::getGrouper));
Map<Integer, Entity> entityMap = entityList.stream() .collect(Collectors.toMap(Entity::getKey, entity -> entity));