1. 分组
代码语言:javascript复制Map<Integer, List<Entity>> groupBy
= entityList.stream()
.collect(Collectors.groupingBy(Entity::getGrouper));
2. 转MAP
代码语言:javascript复制Map<Integer, Entity> entityMap
= entityList.stream()
.collect(Collectors.toMap(Entity::getKey, entity -> entity));