Stream 流对集合根据对象的指定属性去重
直接看例子
// TODO 对数据库查询出来的数据根据bladeNo属性进行去重
List inspectBladesList = inspectBlades.stream().collect(
// 将集合先放到 treeSet 集合然后将他们转换创建新的集合
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(InspectBlade::getBladeNo))), ArrayList::new
)
);