Java list<对象> 整个对象比较 取交集 差集


  //取差集
                    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()));
















免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM