天天看點

map三種指派

map

map String—>String

map String–>Object

map String–>List<對象>

Map<Long, User> userMap = userRes.getData().stream().collect(Collectors.toMap(User::getId, i -> i));

List userChannelList = userChannelRemoteService.listAll().getData();

Map<String, String> userChannelMap = userChannelList.stream()

.collect(Collectors.toMap(UserChannel::getChannelCode, UserChannel::getChannelName));

if (CollectionUtil.isNotEmpty(sysDataDictList)) {

Map<String, List> map = sysDataDictList.stream()

.collect(Collectors.groupingBy(SysDataDict::getDictGroup));

map.forEach((key, value) -> {

itemConfigRespList.add(getCollectionItemConfigResp(key, value));

});

}