mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-07 15:39:29 +00:00
Polish CompositeMap and CollectionUtils
This commit is contained in:
@@ -546,12 +546,11 @@ public abstract class CollectionUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map that combines the provided maps. Invoking
|
||||
* {@link Map#put(Object, Object)} on the returned map will apply
|
||||
* {@code putFunction}, or will throw an
|
||||
* {@link UnsupportedOperationException} {@code putFunction} is
|
||||
* {@code null}. The same applies to {@link Map#putAll(Map)} and
|
||||
* {@code putAllFunction}.
|
||||
* Return a map that combines the provided maps.
|
||||
* <p>Invoking {@link Map#put(Object, Object)} on the returned map will apply
|
||||
* {@code putFunction}, or will throw an {@link UnsupportedOperationException}
|
||||
* if {@code putFunction} is {@code null}. The same applies to
|
||||
* {@link Map#putAll(Map)} and {@code putAllFunction}.
|
||||
* <p>In the case of a key collision, {@code first} takes precedence over
|
||||
* {@code second}. In other words, entries in {@code second} with a key
|
||||
* that is also mapped by {@code first} are effectively ignored.
|
||||
|
||||
@@ -77,22 +77,12 @@ final class CompositeMap<K, V extends @Nullable Object> implements Map<K, V> {
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
if (this.first.containsKey(key)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return this.second.containsKey(key);
|
||||
}
|
||||
return this.first.containsKey(key) || this.second.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
if (this.first.containsValue(value)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return this.second.containsValue(value);
|
||||
}
|
||||
return this.first.containsValue(value) || this.second.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user