Class ForwardingMap<K,V>
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- com.google.common.collect.ForwardingMap<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
- Direct Known Subclasses:
EnumBiMap
,EnumHashBiMap
,ForwardingConcurrentMap
,ForwardingSortedMap
,ImmutableClassToInstanceMap
,ImmutableTypeToInstanceMap
,MutableClassToInstanceMap
,MutableTypeToInstanceMap
@GwtCompatible public abstract class ForwardingMap<K,V> extends ForwardingObject implements java.util.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
ForwardingMap
forward 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 overrideputAll
as well, either providing your own implementation, or delegating to the providedstandardPutAll
method.Each of the
standard
methods, 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 aSortedMap
whose comparator is not consistent withequals
.The
standard
methods 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 void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
boolean
equals(java.lang.Object object)
V
get(java.lang.Object key)
int
hashCode()
boolean
isEmpty()
java.util.Set<K>
keySet()
V
put(K key, V value)
void
putAll(java.util.Map<? extends K,? extends V> map)
V
remove(java.lang.Object object)
int
size()
java.util.Collection<V>
values()
-
Methods inherited from class com.google.common.collect.ForwardingObject
toString
-
-
-
-
Method Detail
-
remove
public V remove(java.lang.Object object)
-
containsKey
public boolean containsKey(@Nullable java.lang.Object key)
-
containsValue
public boolean containsValue(@Nullable java.lang.Object value)
-
get
public V get(@Nullable java.lang.Object key)
-
values
public java.util.Collection<V> values()
-
equals
public boolean equals(@Nullable java.lang.Object object)
-
-