//取差集 List<对象> differenceSet = enterpriseUserList.stream().filter(item -> !enterpriseUserPowerVos.contains(item) ).collect(Collectors.toList()); if (differenceSet.size() > 0){ baseUserMapper.addUserResource(interfaceResourceId,menuId,differenceSet,0); } //取交集 List<对象> intersection = enterpriseUserList.stream().filter(enterpriseUserPowerVos::contains ).collect(Collectors.toList());
需要注意的是 整个对象参数比较的话 需要在对应的对象上打上
@EqualsAndHashCode 标签
List<int/string/long> 转 map
Map<Long, Long> map = roleLists.stream().collect(Collectors.toMap(v -> v, Function.identity()));