时间:2022-08-01 10:47:25 | 栏目:JAVA代码 | 点击:次
List<Data> data1 = new ArrayList<>(); data1.add(new Data(7, 15)); data1.add(new Data(2, 17)); data1.add(new Data(2, 17)); List<Data> data2 = new ArrayList<>(); data2.add(new Data(1, 11)); data2.add(new Data(10, 9)); data2.add(new Data(10, 9)); data2.add(new Data(7, 15)); data2.add(new Data(2, 17)); data2.add(new Data(2, 17)); List<Data> result = data2.stream() .filter(d1 -> data1.stream() .noneMatch(d2 -> Objects.equals(d1.getId(), d2.getId())) ).collect(Collectors.toList()); System.out.println(result);
结果:
.noneMatch(d2 -> Objects.equals(d1.getId(), d2.getId()) && Objects.equals(d1.getId(), d2.getId()))
List<String> delTagGroup = new ArrayList<>();//需要删除的 List<String> originGroupId = qwTagGroupEntityList.stream().map(QwTagGroupEntity::getGroupId).collect(Collectors.toList());//原有的 List<String> newGroupId = corpTagList.getTag_group().stream().map(CorpTagList.TagGroupBean::getGroup_id).collect(Collectors.toList());//新的 delTagGroup = originGroupId.stream().filter(o->!newGroupId.contains(o)).collect(Collectors.toList());//新的不在原有里面的