方式1
public staticPredicate distinctByKey(Function super T, ?> keyExtractor) { Map
使用方法:用Stream接口的 filter()接收为参数
Listlists = list.stream().filter(distinctByKey(b->b.getTid())).collect(Collectors.toList());
方式2
存在重复数据的问题,这里使用stream流的衍生功能,去除一个对象中的部分元素的重复如下:
ArrayListcollect1 = patentDtoList.stream().collect(Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>( Comparator.comparing(p->p.getPatentName() + ";" + p.getLevel()))), ArrayList::new)



