mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
处理了Collectors.toMap未指定key重复策略 导致的java.lang.IllegalStateException: Duplicate key 问题
This commit is contained in:
parent
bebf191c19
commit
651bca7c99
@ -30,7 +30,7 @@ public class CollStreamUtil {
|
|||||||
if (CollUtil.isEmpty(collection)) {
|
if (CollUtil.isEmpty(collection)) {
|
||||||
return Collections.emptyMap();
|
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)) {
|
if (CollUtil.isEmpty(collection)) {
|
||||||
return Collections.emptyMap();
|
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
|
return collection
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.groupingBy(key1, Collectors.toMap(key2, Function.identity())));
|
.collect(Collectors.groupingBy(key1, Collectors.toMap(key2, Function.identity(), (l, r) -> l)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user