// xxx 表示你需要去重的字段 列如(o -> o.id())  返回已经去重集合

List<AddEventAndProperty> nameDistinct = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> xxx))), ArrayList::new));

// 通过多个字段去重,返回已经去重集合

List<AddEventAndProperty> distinctClass = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.id() + ";" + o.getName()))), ArrayList::new));

// 可以通过集合的size判断是否有重复数据

相关文章:

  • 2021-11-18
  • 2021-11-18
  • 2021-07-08
  • 2022-12-23
  • 2021-11-18
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-18
  • 2021-11-17
  • 2021-12-09
  • 2021-11-18
  • 2021-12-11
  • 2022-12-23
相关资源
相似解决方案