一段枯  
自认惊叹的桥段,终沦为老生常谈。

得到一些数据,List<Map<String,String>>  里面存的代码值和代码类型,

 

list=Arrays.asList(Immutable.of("code","001","type","‘充值’),Immutable.of("code","002","type","‘充值2’),Immutable.of("code","003","type","‘充值3’));

现在需要将list转为map,数据格式为,Immutable.of("001","充值","002","充值2',“003”,"充值3");

Map map=new Hash();

list.forEach(li->map.merge(li.get(“code”),li.get("type"),

(k,v)->{

throw new RuntimeException("充值类型代码值重复");

}

));

 

不适用本次需求,
Map<String, String> _czType = czType.stream().flatMap(map -> map.entrySet().stream())
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue
));
posted on 2022-01-17 11:10  唯梦闲人  阅读(233)  评论(0编辑  收藏  举报
 
……