将list分组转成map

/**
 * 将list分组转成map
 * @param dataList
 * @param groupField
 * @return
 */
public Map<String, List<Map<String, Object>>> converterListToMap(List<Map<String,Object>> dataList,String groupField){
    if(AOSUtils.isEmpty(dataList)){
        return null;
    }
    Map<String, List<Map<String, Object>>> collect = dataList.stream()
            .filter(map -> AOSUtils.isNotEmpty(map.get(groupField)))
            .collect(Collectors.groupingBy(map -> (String) map.get(groupField)));
    return collect;
}

你可能感兴趣的:(stream)