@GwtCompatible abstract class AbstractListMultimap<K,V> extends AbstractMapBasedMultimap<K,V> implements ListMultimap<K,V>
ListMultimap interface. It's a wrapper
around AbstractMapBasedMultimap that converts the returned collections into
Lists. The createCollection() method must return a List.AbstractMapBasedMultimap.NavigableAsMap, AbstractMapBasedMultimap.NavigableKeySet, AbstractMapBasedMultimap.WrappedNavigableSetAbstractMultimap.Values| Modifier and Type | Field and Description |
|---|---|
private static long |
serialVersionUID |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractListMultimap(java.util.Map<K,java.util.Collection<V>> map)
Creates a new multimap that uses the provided map.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<K,java.util.Collection<V>> |
asMap()
Returns a view of this multimap as a
Map from each distinct key
to the nonempty collection of that key's associated values. |
(package private) abstract java.util.List<V> |
createCollection()
Creates the collection of values for a single key.
|
(package private) java.util.List<V> |
createUnmodifiableEmptyCollection()
Creates an unmodifiable, empty collection of values.
|
boolean |
equals(java.lang.Object object)
Compares the specified object to this multimap for equality.
|
java.util.List<V> |
get(K key)
Returns a view collection of the values associated with
key in this
multimap, if any. |
boolean |
put(K key,
V value)
Stores a key-value pair in the multimap.
|
java.util.List<V> |
removeAll(java.lang.Object key)
Removes all values associated with the key
key. |
java.util.List<V> |
replaceValues(K key,
java.lang.Iterable<? extends V> values)
Stores a collection of values with the same key, replacing any existing
values for that key.
|
backingMap, clear, containsKey, createAsMap, createCollection, createKeySet, entries, entryIterator, setMap, size, unmodifiableCollectionSubclass, valueIterator, values, wrapCollectioncontainsEntry, containsValue, createEntries, createKeys, createValues, hashCode, isEmpty, keys, keySet, putAll, putAll, remove, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitclear, containsEntry, containsKey, containsValue, entries, hashCode, isEmpty, keys, keySet, putAll, putAll, remove, size, valuesprivate static final long serialVersionUID
abstract java.util.List<V> createCollection()
AbstractMapBasedMultimapCollections 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.
createCollection in class AbstractMapBasedMultimap<K,V>java.util.List<V> createUnmodifiableEmptyCollection()
AbstractMapBasedMultimapThis is used in AbstractMapBasedMultimap.removeAll(java.lang.Object) on an empty key.
createUnmodifiableEmptyCollection in class AbstractMapBasedMultimap<K,V>public java.util.List<V> get(@Nullable K key)
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.
The returned collection is not serializable.
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.
public java.util.List<V> removeAll(@Nullable java.lang.Object key)
key.
Once this method returns, key will not be mapped to any values,
so it will not appear in Multimap.keySet(), Multimap.asMap(), or any other
views.
The returned collection is immutable.
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.
removeAll in interface ListMultimap<K,V>removeAll in interface Multimap<K,V>removeAll in class AbstractMapBasedMultimap<K,V>public java.util.List<V> replaceValues(@Nullable K key, java.lang.Iterable<? extends V> values)
If values is empty, this is equivalent to
removeAll(key).
The returned collection is immutable.
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.
replaceValues in interface ListMultimap<K,V>replaceValues in interface Multimap<K,V>replaceValues in class AbstractMapBasedMultimap<K,V>public java.util.Map<K,java.util.Collection<V>> asMap()
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.
Though the method signature doesn't say so explicitly, the returned map
has List values.
public boolean equals(@Nullable
java.lang.Object object)
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.