java Stream對map進行操作

//===============  跨渠道實現共享組邏輯    ==============================
            //根據MerchantGroup查詢共享組內所有信息
            List<RouterAgreementRelation> merchantGroupInfo = routerAgreementRelationMapper.selectByMerchantGroup(merchantInfo.getMerchantGroup());
            //找出所有group內的商戶號
            List<String> merchantList = merchantGroupInfo.stream().map(RouterAgreementRelation::getMerchantNo).collect(Collectors.toList());
            List<String> channelCodes = merchantGroupInfo.stream().map(RouterAgreementRelation::getChannelCode).distinct().collect(Collectors.toList());
            //剔除原有channelCode
            channelCodes.remove(channelCode);
            if (channelCodes.size() > 0) {
                for(String temChannelCode : channelCodes){
                    Map<String, FourFactorSignModel> fourFactorSignModelMap_ofOtherchannel = retriveSignupInfoFromAuth(request, temChannelCode);
                    //過濾不屬於該共享組內的簽約信息
                    fourFactorSignModelMap_ofOtherchannel = fourFactorSignModelMap_ofOtherchannel.entrySet().stream()
                    .filter((e)->{return merchantList.contains(e.getKey());})
                    .collect(Collectors.toMap((e) -> (String)e.getKey(), (e) -> e.getValue()));
                    fourFactorSignModelMap.putAll(fourFactorSignModelMap_ofOtherchannel);
                }
            }
//===============================================================

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章