!421 处理了Collectors.toMap未指定key重复策略 导致的java.lang.IllegalStateException: Duplicate key 问题

Merge pull request !421 from 阿超/v5-dev
This commit is contained in:
Looly 2021-09-29 03:37:29 +00:00 committed by Gitee
commit 43e24c1498

View File

@ -30,7 +30,7 @@ public class CollStreamUtil {
if (CollUtil.isEmpty(collection)) {
return Collections.emptyMap();
}
return collection.stream().collect(Collectors.toMap(key, Function.identity()));
return collection.stream().collect(Collectors.toMap(key, Function.identity(), (l, r) -> l));
}
/**
@ -49,7 +49,7 @@ public class CollStreamUtil {
if (CollUtil.isEmpty(collection)) {
return Collections.emptyMap();
}
return collection.stream().collect(Collectors.toMap(key, value));
return collection.stream().collect(Collectors.toMap(key, value, (l, r) -> l));
}
/**
@ -110,7 +110,7 @@ public class CollStreamUtil {
}
return collection
.stream()
.collect(Collectors.groupingBy(key1, Collectors.toMap(key2, Function.identity())));
.collect(Collectors.groupingBy(key1, Collectors.toMap(key2, Function.identity(), (l, r) -> l)));
}
/**