你的赛博博客

探索数字未来的边界

copy 集合List

复制list集合
BeanUtil.copyToList(problemTypeList, ProblemTypeVo.class);


stream 根据属性拼接字符串
List<String> nameList = personList.stream().map(Person::getName).collect(Collectors.toList());

stream 分组
Map<String, List<ProblemUserVo>> collect = userVos.stream().collect(Collectors.groupingBy(ProblemUserVo::getProblemType));

根据name,sex两个属性去重
List<ProblemUserVo> unique = userVos.stream().collect(
Collectors. collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getProblemType() + ";" + o.getCategory()))), ArrayList::new)
);
posted @ 2023-02-22 09:10  Aoul  阅读(75)  评论(0)    收藏  举报