Package com.google.common.collect
Class ForwardingSetMultimap<K extends @Nullable Object,V extends @Nullable Object>
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- com.google.common.collect.ForwardingMultimap<K,V>
-
- com.google.common.collect.ForwardingSetMultimap<K,V>
-
- All Implemented Interfaces:
Multimap<K,V>
,SetMultimap<K,V>
- Direct Known Subclasses:
ForwardingSortedSetMultimap
@GwtCompatible public abstract class ForwardingSetMultimap<K extends @Nullable Object,V extends @Nullable Object> extends ForwardingMultimap<K,V> implements SetMultimap<K,V>
A set multimap which forwards all its method calls to another set multimap. Subclasses should override one or more methods to modify the behavior of the backing multimap as desired per the decorator pattern.default
method warning: This class does not forward calls todefault
methods. Instead, it inherits their default implementations. When those implementations invoke methods, they invoke methods on theForwardingSetMultimap
.- Since:
- 3.0
- Author:
- Kurt Alfred Kluever
-
-
Constructor Summary
Constructors Constructor Description ForwardingSetMultimap()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract SetMultimap<K,V>
delegate()
Returns the backing delegate instance that methods are forwarded to.Set<Map.Entry<K,V>>
entries()
Returns a view collection of all key-value pairs contained in this multimap, asMap.Entry
instances.Set<V>
get(K key)
Returns a view collection of the values associated withkey
in this multimap, if any.Set<V>
removeAll(Object key)
Removes all values associated with the keykey
.Set<V>
replaceValues(K key, Iterable<? extends V> values)
Stores a collection of values with the same key, replacing any existing values for that key.-
Methods inherited from class com.google.common.collect.ForwardingMultimap
asMap, clear, containsEntry, containsKey, containsValue, equals, hashCode, isEmpty, keys, keySet, put, putAll, putAll, remove, size, values
-
Methods inherited from class com.google.common.collect.ForwardingObject
toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.common.collect.Multimap
clear, containsEntry, containsKey, containsValue, forEach, hashCode, isEmpty, keys, keySet, put, putAll, putAll, remove, size, values
-
Methods inherited from interface com.google.common.collect.SetMultimap
asMap, equals
-
-
-
-
Constructor Detail
-
ForwardingSetMultimap
public ForwardingSetMultimap()
-
-
Method Detail
-
delegate
protected abstract SetMultimap<K,V> delegate()
Description copied from class:ForwardingObject
Returns the backing delegate instance that methods are forwarded to. Abstract subclasses generally override this method with an abstract method that has a more specific return type, such asForwardingSet.delegate()
. Concrete subclasses override this method to supply the instance being decorated.
-
entries
public Set<Map.Entry<K,V>> entries()
Description copied from interface:Multimap
Returns a view collection of all key-value pairs contained in this multimap, asMap.Entry
instances.Changes to the returned collection or the entries it contains will update the underlying multimap, and vice versa. However, adding to the returned collection is not possible.
- Specified by:
entries
in interfaceMultimap<K extends @Nullable Object,V extends @Nullable Object>
- Specified by:
entries
in interfaceSetMultimap<K extends @Nullable Object,V extends @Nullable Object>
- Overrides:
entries
in classForwardingMultimap<K extends @Nullable Object,V extends @Nullable Object>
-
get
public Set<V> get(K key)
Description copied from interface:Multimap
Returns a view collection of the values associated withkey
in this multimap, if any. Note that whencontainsKey(key)
is false, this returns an empty collection, notnull
.Changes to the returned collection will update the underlying multimap, and vice versa.
-
removeAll
@CanIgnoreReturnValue public Set<V> removeAll(@CheckForNull Object key)
Description copied from interface:Multimap
Removes all values associated with the keykey
.Once this method returns,
key
will not be mapped to any values, so it will not appear inMultimap.keySet()
,Multimap.asMap()
, or any other views.- Specified by:
removeAll
in interfaceMultimap<K extends @Nullable Object,V extends @Nullable Object>
- Specified by:
removeAll
in interfaceSetMultimap<K extends @Nullable Object,V extends @Nullable Object>
- Overrides:
removeAll
in classForwardingMultimap<K extends @Nullable Object,V extends @Nullable Object>
- Returns:
- the values that were removed (possibly empty). The returned collection may be modifiable, but updating it will have no effect on the multimap.
-
replaceValues
@CanIgnoreReturnValue public Set<V> replaceValues(K key, Iterable<? extends V> values)
Description copied from interface:Multimap
Stores a collection of values with the same key, replacing any existing values for that key.If
values
is empty, this is equivalent toremoveAll(key)
.- Specified by:
replaceValues
in interfaceMultimap<K extends @Nullable Object,V extends @Nullable Object>
- Specified by:
replaceValues
in interfaceSetMultimap<K extends @Nullable Object,V extends @Nullable Object>
- Overrides:
replaceValues
in classForwardingMultimap<K extends @Nullable Object,V extends @Nullable Object>
- Returns:
- the collection of replaced values, or an empty collection if no values were previously associated with the key. The collection may be modifiable, but updating it will have no effect on the multimap.
-
-