List 对象集合去重



 List data = newByBusinessMapper.selectByExample(example);
  /**
         * 多个属性对比
         */
        data = data.stream().collect(Collectors
                .collectingAndThen(
                        Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o-> (o.getBusinessId() + o.getStatDate() + o.getDepartmentId() + o.getOfficeId() + o.getResourceType())))),
                        ArrayList::new));
        /**
         * 单个属性对比
         */
        data = data.stream().collect(Collectors
                .collectingAndThen(
                        Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o-> (o.getBusinessId())))),
                        ArrayList::new));

你可能感兴趣的:(list,数据结构)