Polish CompositeMap and CollectionUtils

This commit is contained in:
Sam Brannen
2026-10-02 16:41:39 +02:00
parent f5a7123044
commit c259185b52
2 changed files with 7 additions and 18 deletions
@@ -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