list 类型转换 Map
/**
* list 类型转换
*
* @param list source
* @param keyMapper keyMapper
* @param <T> T
* @param <K> K
* @return Map
*/
public static <T, K> Map<K, List<T>> groupBy(List<T> list, Function<T, K> keyMapper) {
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyMap();
}
return list.stream().collect(Collectors.groupingBy(keyMapper));
}