|
22 | 22 | import java.util.List;
|
23 | 23 | import java.util.Map;
|
24 | 24 | import java.util.Set;
|
| 25 | +import java.util.function.BiConsumer; |
25 | 26 |
|
26 | 27 | import org.springframework.lang.Nullable;
|
27 | 28 |
|
@@ -69,15 +70,13 @@ public void add(K key, @Nullable V value) {
|
69 | 70 |
|
70 | 71 | @Override
|
71 | 72 | public void addAll(K key, List<? extends V> values) {
|
72 |
| - List<V> currentValues = this.targetMap.computeIfAbsent(key, k -> new ArrayList<>(1)); |
| 73 | + List<V> currentValues = this.targetMap.computeIfAbsent(key, k -> new ArrayList<>(values.size())); |
73 | 74 | currentValues.addAll(values);
|
74 | 75 | }
|
75 | 76 |
|
76 | 77 | @Override
|
77 | 78 | public void addAll(MultiValueMap<K, V> values) {
|
78 |
| - for (Entry<K, List<V>> entry : values.entrySet()) { |
79 |
| - addAll(entry.getKey(), entry.getValue()); |
80 |
| - } |
| 79 | + values.forEach(this::addAll); |
81 | 80 | }
|
82 | 81 |
|
83 | 82 | @Override
|
@@ -138,6 +137,12 @@ public List<V> put(K key, List<V> value) {
|
138 | 137 | return this.targetMap.put(key, value);
|
139 | 138 | }
|
140 | 139 |
|
| 140 | + @Override |
| 141 | + @Nullable |
| 142 | + public List<V> putIfAbsent(K key, List<V> value) { |
| 143 | + return this.targetMap.putIfAbsent(key, value); |
| 144 | + } |
| 145 | + |
141 | 146 | @Override
|
142 | 147 | @Nullable
|
143 | 148 | public List<V> remove(Object key) {
|
@@ -169,6 +174,11 @@ public Set<Entry<K, List<V>>> entrySet() {
|
169 | 174 | return this.targetMap.entrySet();
|
170 | 175 | }
|
171 | 176 |
|
| 177 | + @Override |
| 178 | + public void forEach(BiConsumer<? super K, ? super List<V>> action) { |
| 179 | + this.targetMap.forEach(action); |
| 180 | + } |
| 181 | + |
172 | 182 | @Override
|
173 | 183 | public boolean equals(@Nullable Object other) {
|
174 | 184 | return (this == other || this.targetMap.equals(other));
|
|
0 commit comments