list集合取交集
2018-11-26 本文已影响0人
王叶叶m
查询
List<Goods> result = new ArrayList<>();
List<Goods> goodsthirdIdList = goodsRepository.selGoodsByThirdId(ThirdId());
if(result.isEmpty()) {
result = goodsthirdIdList;
} else {
result = result.stream()
.filter(t->goodsthirdIdList.stream().
anyMatch(t2->t2.getGoodsId()==t.getGoodsId()))
.collect(Collectors.toList());
}