前言:
如今兄弟们对“map合并方式”大概比较关切,姐妹们都想要了解一些“map合并方式”的相关知识。那么小编也在网络上网罗了一些对于“map合并方式””的相关资讯,希望同学们能喜欢,各位老铁们一起来学习一下吧!Map<Long, Set<String>> eduRepeatUserDTOMap = crmUserLearnStatService.getEduRepeatUserDTOList(campRef);Map<Long, Set<String>> doubleUserRebuyPurchaseMap = getDoubleUserPurchaseUids(campus, campRef, repeatCampusStr, businessType);Map<Long, Set<String>> resultMerge = mergeMapValueAppend(userRealRebuyPurchaseMap, eduRepeatUserDTOMap);Map<Long, Set<String>> result = mergeMapValueAppend(resultMerge, doubleUserRebuyPurchaseMap);
private Map<Long, Set<String>> mergeMapValueAppend(Map<Long, Set<String>> map1, Map<Long, Set<String>> map2) { if (MapUtils.isEmpty(map1)) { return map2; } if (MapUtils.isEmpty(map2)) { return map1; } map1.forEach((k, v) -> map2.merge(k, v, (v1, v2) -> { if (CollectionUtils.isNotEmpty(v1) && CollectionUtils.isNotEmpty(v2)) { Set<String> set = Sets.newHashSet(); set.addAll(v1); set.addAll(v2); return set; } else if (CollectionUtils.isNotEmpty(v1) && CollectionUtils.isEmpty(v2)) { return v1; } else if (CollectionUtils.isEmpty(v1) && CollectionUtils.isNotEmpty(v2)) { return v2; } return v1; })); return map2;}
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。