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

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

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

Basic implementation of the ListMultimap interface. It's a wrapper around AbstractMapBasedMultimap that converts the returned collections into Lists. The createCollection method must return a List.
Author
Jared Levy
Since
2.0

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected
AbstractListMultimap(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.ListMultimap.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 List<V>
createCollection()

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

Creates the collection of values for a single key.
pack-priv List<V>
public boolean
equals(Object
the reference object with which to compare.
object
)

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

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

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

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

Implements com.google.common.collect.ListMultimap.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 always
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 List<V>
public List<V>
replaceValues(K key, Iterable<? extends V> values)

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

Implements com.google.common.collect.ListMultimap.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:
backingMapclearcontainsKeycreateAsMapcreateCollectioncreateEntriescreateKeyscreateKeySetcreateMaybeNavigableAsMapcreateMaybeNavigableKeySetcreateValuesentriesentryIteratorentrySpliteratorforEachsetMapsizevalueIteratorvaluesvalueSpliteratorwrapList

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

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

Constructor Detail

AbstractListMultimapback to summary
protected AbstractListMultimap(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.ListMultimap.asMap, com.google.common.collect.Multimap.asMap.

Doc from com.google.common.collect.ListMultimap.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 List. To obtain this map with the more specific generic type Map<K, List<V>>, call Multimaps#asMap(ListMultimap) instead.

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

Annotations
@Override
createCollectionback to summary
pack-priv abstract List<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:List<V>

an empty collection of values

Annotations
@Override
createUnmodifiableEmptyCollectionback to summary
pack-priv List<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
equalsback to summary
public boolean equals(Object object)

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

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

Compares the specified object to this multimap for equality.

Two ListMultimap instances are equal if, for each key, they contain the same values in the same order. If the value orderings disagree, the multimaps will not be considered equal.

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 List<V> get(K key)

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

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

Doc from com.google.common.collect.ListMultimap.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 the values for a given key may have duplicates and follow the insertion ordering, this method returns a List, instead of the java.util.Collection specified in the Multimap interface.

Because the values for a given key may have duplicates and follow the insertion ordering, this method returns a List, 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 always

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

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

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

Doc from com.google.common.collect.ListMultimap.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 the values for a given key may have duplicates and follow the insertion ordering, this method returns a List, instead of the java.util.Collection specified in the Multimap interface.

Because the values for a given key may have duplicates and follow the insertion ordering, this method returns a List, instead of the Collection specified in the Multimap interface.

Returns:List<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 List<V> replaceValues(K key, Iterable<? extends V> values)

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

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

Doc from com.google.common.collect.ListMultimap.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 the values for a given key may have duplicates and follow the insertion ordering, this method returns a List, instead of the java.util.Collection specified in the Multimap interface.

Because the values for a given key may have duplicates and follow the insertion ordering, this method returns a List, instead of the Collection specified in the Multimap interface.

Returns:List<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