stream重复Key的处理

Posted on 2020-02-20 09:09  wzhw2015  阅读(815)  评论(0编辑  收藏  举报

Map<String, List<Model>> modelMap = modelList
.stream()
.collect(Collectors
.toMap(model -> model.getDate(),
model -> new ArrayList<Model>(Arrays.asList(model)),
(List<Model> oldList,
List<Model> newList) -> {
oldList.addAll(newList);
return oldList;
}));

Copyright © 2024 wzhw2015
Powered by .NET 9.0 on Kubernetes