使用:
collectingAndThen 和 toCollection 方法 , 然后结合TreeSet的特性 ,完成对象指定属性去重
使用事例:
List<Degree> degreeList = statDegreeService.list();
// 对查询的结果:档位做去重处理
degreeList = degreeList.stream().collect(
collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(Degree::getDegree))), ArrayList::new)
);