mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
refactor(core:MapUtil): simplify code
This commit is contained in:
parent
097370550e
commit
96499b96b5
@ -509,13 +509,7 @@ public class MapUtil {
|
||||
return map;
|
||||
}
|
||||
for (final Map.Entry<K, V> pair : entries) {
|
||||
final List<V> values;
|
||||
if (map.containsKey(pair.getKey())) {
|
||||
values = map.get(pair.getKey());
|
||||
} else {
|
||||
values = new ArrayList<>();
|
||||
map.put(pair.getKey(), values);
|
||||
}
|
||||
final List<V> values = map.computeIfAbsent(pair.getKey(), k -> new ArrayList<>());
|
||||
values.add(pair.getValue());
|
||||
}
|
||||
return map;
|
||||
|
Loading…
Reference in New Issue
Block a user