对象数组根据某一个属性转换为Map<String,List>
LambdaQueryWrapper<UacCode> queryWrapper = new QueryWrapper<UacCode>().lambda();
queryWrapper.in(UacCode::getCodeType,codeTypes);
List<UacCode> list = codeDao.selectList(queryWrapper);
Map<String, List<UacCode>> codeMap = list.stream().collect(Collectors.groupingBy(UacCode::getCodeType));
数据先筛选,在返回其中一个属性
List<Face> faces = person.getFaces();
List<Long> faceIdList = faces.stream().filter(face -> ObjectUtils.isNotEmpty(face.getId())).map(face -> face.getId()).collect(Collectors.toList());
转换为字符串,类似js的join
stringList.stream().collect(Collectors.joining(","))
返回账号id-count对应map
accounts.stream().collect(Collectors.toMap(Account::getId, Account::getUsername));
返回ID-实体对象map
accounts.stream().collect(Collectors.toMap(Account::getId, account -> account));
key值重复的处理,以及指定返回map具体实现类
accounts.stream().collect(Collectors.toMap(Account::getUsername, Function.identity(), (key1, key2) -> key2, LinkedHashMap::new));