Class ForwardingMap<K,V>
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- com.google.common.collect.ForwardingMap<K,V>
-
- All Implemented Interfaces:
Map<K,V>
- Direct Known Subclasses:
EnumBiMap,EnumHashBiMap,ForwardingConcurrentMap,ForwardingSortedMap,ImmutableClassToInstanceMap,ImmutableTypeToInstanceMap,MutableClassToInstanceMap,MutableTypeToInstanceMap
@GwtCompatible public abstract class ForwardingMap<K,V> extends ForwardingObject implements Map<K,V>
A map which forwards all its method calls to another map. Subclasses should override one or more methods to modify the behavior of the backing map as desired per the decorator pattern.Warning: The methods of
ForwardingMapforward indiscriminately to the methods of the delegate. For example, overridingput(K, V)alone will not change the behavior ofputAll(java.util.Map<? extends K, ? extends V>), which can lead to unexpected behavior. In this case, you should overrideputAllas well, either providing your own implementation, or delegating to the providedstandardPutAllmethod.Each of the
standardmethods, where appropriate, useObjects.equal(java.lang.Object, java.lang.Object)to test equality for both keys and values. This may not be the desired behavior for map implementations that use non-standard notions of key equality, such as aSortedMapwhose comparator is not consistent withequals.The
standardmethods and the collection views they return are not guaranteed to be thread-safe, even when all of the methods that they depend on are thread-safe.- Since:
- 2.0 (imported from Google Collections Library)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()booleanequals(Object object)Vget(Object key)inthashCode()booleanisEmpty()Set<K>keySet()Vput(K key, V value)voidputAll(Map<? extends K,? extends V> map)Vremove(Object object)intsize()Collection<V>values()-
Methods inherited from class com.google.common.collect.ForwardingObject
toString
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
containsKey
public boolean containsKey(@Nullable Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(@Nullable Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
-