Top Description Fields Constructors Methods
com.google.common.collect

pack-priv abstract Class AbstractSetMultimap<K extends @Nullable Object, V extends @Nullable Object>

extends AbstractMapBasedMultimap<K extends @Nullable Object, V extends @Nullable Object>
implements SetMultimap<K extends @Nullable Object, V extends @Nullable Object>
Class Inheritance
All Implemented Interfaces
com.google.common.collect.SetMultimap, com.google.common.collect.Multimap
Known Direct Subclasses
com.google.common.collect.AbstractSortedSetMultimap, com.google.common.collect.Multimaps.CustomSetMultimap, com.google.common.collect.HashMultimapGwtSerializationDependencies, com.google.common.collect.LinkedHashMultimapGwtSerializationDependencies
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Imports
com.google.common.annotations.GwtCompatible, com.google.errorprone.annotations.CanIgnoreReturnValue, java.util.Collection, .Collections, .Map, .Map.Entry, .Set, javax.annotation.CheckForNull, org.checkerframework.checker.nullness.qual.Nullable

Basic implementation of the SetMultimap interface. It's a wrapper around AbstractMapBasedMultimap that converts the returned collections into Sets. The createCollection method must return a Set.
Author
Jared Levy

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected
AbstractSetMultimap(Map<K, Collection<V>>
place to store the mapping from each key to its corresponding values
map
)

Creates a new multimap that uses the provided map.

Method Summary

Modifier and TypeMethod and Description
public Map<K, Collection<V>>
asMap()

Overrides com.google.common.collect.AbstractMultimap.asMap.

Implements com.google.common.collect.SetMultimap.asMap, com.google.common.collect.Multimap.asMap.

Returns a view of this multimap as a Map from each distinct key to the nonempty collection of that key's associated values.
pack-priv abstract Set<V>
createCollection()

Implements abstract com.google.common.collect.AbstractMapBasedMultimap.createCollection.

Creates the collection of values for a single key.
pack-priv Set<V>
public Set<Map.Entry<K, V>>
entries()

Overrides com.google.common.collect.AbstractMapBasedMultimap.entries.

Implements com.google.common.collect.SetMultimap.entries, com.google.common.collect.Multimap.entries.

Returns a view collection of all key-value pairs contained in this multimap, as Entry instances.
public boolean
equals(Object
the reference object with which to compare.
object
)

Overrides com.google.common.collect.AbstractMultimap.equals.

Implements com.google.common.collect.SetMultimap.equals, com.google.common.collect.Multimap.equals.

Compares the specified object to this multimap for equality.
public Set<V>
get(K key)

Overrides com.google.common.collect.AbstractMapBasedMultimap.get.

Implements com.google.common.collect.SetMultimap.get, com.google.common.collect.Multimap.get.

Returns a view collection of the values associated with key in this multimap, if any.
public boolean

Returns:

true if the method increased the size of the multimap, or false if the multimap already contained the key-value pair
put
(K
key to store in the multimap
key
,
V
value to store in the multimap
value
)

Overrides com.google.common.collect.AbstractMapBasedMultimap.put.

Implements com.google.common.collect.Multimap.put.

Stores a key-value pair in the multimap.
public Set<V>
public Set<V>
replaceValues(K key, Iterable<? extends V> values)

Overrides com.google.common.collect.AbstractMapBasedMultimap.replaceValues.

Implements com.google.common.collect.SetMultimap.replaceValues, com.google.common.collect.Multimap.replaceValues.

Stores a collection of values with the same key, replacing any existing values for that key.
pack-priv <E extends @Nullable Object> Collection<E>
pack-priv Collection<V>
wrapCollection(K key, Collection<V> collection)

Overrides com.google.common.collect.AbstractMapBasedMultimap.wrapCollection.

Generates a decorated collection that remains consistent with the values in the multimap for the provided key.
Inherited from com.google.common.collect.AbstractMapBasedMultimap:
backingMapclearcontainsKeycreateAsMapcreateCollectioncreateEntriescreateKeyscreateKeySetcreateMaybeNavigableAsMapcreateMaybeNavigableKeySetcreateValuesentryIteratorentrySpliteratorforEachsetMapsizevalueIteratorvaluesvalueSpliteratorwrapList

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.google.common.collect.AbstractMapBasedMultimap.serialVersionUID.

Constructor Detail

AbstractSetMultimapback to summary
protected AbstractSetMultimap(Map<K, Collection<V>> map)

Creates a new multimap that uses the provided map.

Parameters
map:Map<K, Collection<V>>

place to store the mapping from each key to its corresponding values

Method Detail

asMapback to summary
public Map<K, Collection<V>> asMap()

Overrides com.google.common.collect.AbstractMultimap.asMap.

Implements com.google.common.collect.SetMultimap.asMap, com.google.common.collect.Multimap.asMap.

Doc from com.google.common.collect.SetMultimap.asMap.

Returns a view of this multimap as a Map from each distinct key to the nonempty collection of that key's associated values. Note that this.asMap().get(k) is equivalent to this.get(k) only when k is a key contained in the multimap; otherwise it returns null as opposed to an empty collection.

Changes to the returned map or the collections that serve as its values will update the underlying multimap, and vice versa. The map does not support put or putAll, nor do its entries support setValue.

Note

The returned map's values are guaranteed to be of type Set. To obtain this map with the more specific generic type Map<K, Set<V>>, call Multimaps#asMap(SetMultimap) instead.

Though the method signature doesn't say so explicitly, the returned map has Set values.

Annotations
@Override
createCollectionback to summary
pack-priv abstract Set<V> createCollection()

Implements abstract com.google.common.collect.AbstractMapBasedMultimap.createCollection.

Doc from com.google.common.collect.AbstractMapBasedMultimap.createCollection.

Creates the collection of values for a single key.

Collections with weak, soft, or phantom references are not supported. Each call to createCollection should create a new instance.

The returned collection class determines whether duplicate key-value pairs are allowed.

Returns:Set<V>

an empty collection of values

Annotations
@Override
createUnmodifiableEmptyCollectionback to summary
pack-priv Set<V> createUnmodifiableEmptyCollection()

Overrides com.google.common.collect.AbstractMapBasedMultimap.createUnmodifiableEmptyCollection.

Doc from com.google.common.collect.AbstractMapBasedMultimap.createUnmodifiableEmptyCollection.

Creates an unmodifiable, empty collection of values.

This is used in removeAll on an empty key.

Annotations
@Override
entriesback to summary
public Set<Map.Entry<K, V>> entries()

Overrides com.google.common.collect.AbstractMapBasedMultimap.entries.

Implements com.google.common.collect.SetMultimap.entries, com.google.common.collect.Multimap.entries.

Doc from com.google.common.collect.SetMultimap.entries.

Returns a view collection of all key-value pairs contained in this multimap, as 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.

Because a SetMultimap has unique values for a given key, this method returns a Set, instead of the java.util.Collection specified in the Multimap interface.

Because a SetMultimap has unique values for a given key, this method returns a Set, instead of the Collection specified in the Multimap interface.

Annotations
@Override
equalsback to summary
public boolean equals(Object object)

Overrides com.google.common.collect.AbstractMultimap.equals.

Implements com.google.common.collect.SetMultimap.equals, com.google.common.collect.Multimap.equals.

Compares the specified object to this multimap for equality.

Two SetMultimap instances are equal if, for each key, they contain the same values. Equality does not depend on the ordering of keys or values.

Parameters
object:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getback to summary
public Set<V> get(K key)

Overrides com.google.common.collect.AbstractMapBasedMultimap.get.

Implements com.google.common.collect.SetMultimap.get, com.google.common.collect.Multimap.get.

Doc from com.google.common.collect.SetMultimap.get.

Returns a view collection of the values associated with key in this multimap, if any. Note that when containsKey(key) is false, this returns an empty collection, not null.

Changes to the returned collection will update the underlying multimap, and vice versa.

Because a SetMultimap has unique values for a given key, this method returns a Set, instead of the java.util.Collection specified in the Multimap interface.

Because a SetMultimap has unique values for a given key, this method returns a Set, instead of the Collection specified in the Multimap interface.

Annotations
@Override
putback to summary
public boolean put(K key, V value)

Overrides com.google.common.collect.AbstractMapBasedMultimap.put.

Implements com.google.common.collect.Multimap.put.

Stores a key-value pair in the multimap.

Parameters
key:K

key to store in the multimap

value:V

value to store in the multimap

Returns:boolean

true if the method increased the size of the multimap, or false if the multimap already contained the key-value pair

Annotations
@CanIgnoreReturnValue
@Override
removeAllback to summary
public Set<V> removeAll(Object key)

Overrides com.google.common.collect.AbstractMapBasedMultimap.removeAll.

Implements com.google.common.collect.SetMultimap.removeAll, com.google.common.collect.Multimap.removeAll.

Doc from com.google.common.collect.SetMultimap.removeAll.

Removes all values associated with the key key.

Once this method returns, key will not be mapped to any values, so it will not appear in keySet(), asMap(), or any other views.

Because a SetMultimap has unique values for a given key, this method returns a Set, instead of the java.util.Collection specified in the Multimap interface.

Because a SetMultimap has unique values for a given key, this method returns a Set, instead of the Collection specified in the Multimap interface.

Returns:Set<V>

Doc from com.google.common.collect.Multimap.removeAll.

the values that were removed (possibly empty). The returned collection may be modifiable, but updating it will have no effect on the multimap.

Annotations
@CanIgnoreReturnValue
@Override
replaceValuesback to summary
public Set<V> replaceValues(K key, Iterable<? extends V> values)

Overrides com.google.common.collect.AbstractMapBasedMultimap.replaceValues.

Implements com.google.common.collect.SetMultimap.replaceValues, com.google.common.collect.Multimap.replaceValues.

Doc from com.google.common.collect.SetMultimap.replaceValues.

Stores a collection of values with the same key, replacing any existing values for that key.

If values is empty, this is equivalent to removeAll(key).

Because a SetMultimap has unique values for a given key, this method returns a Set, instead of the java.util.Collection specified in the Multimap interface.

Any duplicates in values will be stored in the multimap once.

Because a SetMultimap has unique values for a given key, this method returns a Set, instead of the Collection specified in the Multimap interface.

Any duplicates in values will be stored in the multimap once.

Returns:Set<V>

Doc from com.google.common.collect.Multimap.replaceValues.

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.

Annotations
@CanIgnoreReturnValue
@Override
unmodifiableCollectionSubclassback to summary
pack-priv <E extends @Nullable Object> Collection<E> unmodifiableCollectionSubclass(Collection<E> collection)

Overrides com.google.common.collect.AbstractMapBasedMultimap.unmodifiableCollectionSubclass.

Annotations
@Override
wrapCollectionback to summary
pack-priv Collection<V> wrapCollection(K key, Collection<V> collection)

Overrides com.google.common.collect.AbstractMapBasedMultimap.wrapCollection.

Doc from com.google.common.collect.AbstractMapBasedMultimap.wrapCollection.

Generates a decorated collection that remains consistent with the values in the multimap for the provided key. Changes to the multimap may alter the returned collection, and vice versa.

Annotations
@Override