一、 list转map
1. list 转 map <String, Object>
Map<String, BasicCountryDTO> countryMap = countryList.stream().collect(Collectors.toMap(BasicCountryDTO::getCountryCode, t -> t));
2. list 转 map <String,String>
Map<String, String> productTypeMap = productTypeList.stream().collect(Collectors.toMap(BasicDictDTO::getCode, BasicDictDTO::getName));
3. list 转map <String,List<Object>>
Map<String,List<SysUserDTO>> um = us.stream().collect(Collectors.groupingBy(SysUserDTO::getUserAccount));
二、list 根据某个字段转list
List<String> accountList = auditUserList.stream().map(SysUserDTO::getUserAccount).collect(Collectors.toList());
三、1.根据key sum
Map<String, Integer> sumMap = list.stream().collect(Collectors.groupingBy(item -> item.getA() +item.getB(), Collectors.summingInt(ClassA::getQty)));
2.排序
List<ClassA> sortClass = list.stream().sorted(Comparator.comparing(ClassA::getField)).collect(Collectors.toList());
四、转map 保持顺序
LinkedHashMap<Integer, List<Person>> ageMap = personsSort.stream().sorted(Comparator.comparingInt(Person::getAge)).collect(Collectors.groupingBy(Person::getAge, LinkedHashMap::new, Collectors.toList()));
五、增加,处理
String chainIds = Arrays.stream(chainIdArray).collect(Collectors.joining(CommonConst.COMMA));