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

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

extends Object
implements Multimap<K extends @Nullable Object, V extends @Nullable Object>
Class Inheritance
All Implemented Interfaces
com.google.common.collect.Multimap
Known Direct Subclasses
com.google.common.collect.BaseImmutableMultimap, com.google.common.collect.FilteredEntryMultimap, com.google.common.collect.FilteredKeyMultimap, com.google.common.collect.LinkedListMultimap, com.google.common.collect.Multimaps.MapMultimap, com.google.common.collect.Multimaps.TransformedEntriesMultimap, com.google.common.collect.AbstractMapBasedMultimap
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

A skeleton Multimap implementation, not necessarily in terms of a Map.
Author
Louis Wasserman

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
private transient Map<K, Collection<V>>
private transient Collection<Map.Entry<K, V>>
private transient Multiset<K>
private transient Set<K>
private transient Collection<V>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

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

Implements 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.
public boolean
containsEntry(Object key, Object value)

Implements com.google.common.collect.Multimap.containsEntry.

Returns true if this multimap contains at least one key-value pair with the key key and the value value.
public boolean
containsValue(Object value)

Implements com.google.common.collect.Multimap.containsValue.

Returns true if this multimap contains at least one key-value pair with the value value.
pack-priv abstract Map<K, Collection<V>>
pack-priv abstract Collection<Map.Entry<K, V>>
pack-priv abstract Multiset<K>
pack-priv abstract Set<K>
pack-priv abstract Collection<V>
public Collection<Map.Entry<K, V>>
entries()

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

Returns a view collection of all key-value pairs contained in this multimap, as Entry instances.
pack-priv abstract Iterator<Map.Entry<K, V>>
pack-priv Spliterator<Map.Entry<K, V>>
public boolean
equals(Object
the reference object with which to compare.
object
)

Overrides java.lang.Object.equals.

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

Compares the specified object with this multimap for equality.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements com.google.common.collect.Multimap.hashCode.

Returns the hash code for this multimap.
public boolean
isEmpty()

Implements com.google.common.collect.Multimap.isEmpty.

Returns true if this multimap contains no key-value pairs.
public Multiset<K>
keys()

Implements com.google.common.collect.Multimap.keys.

Returns a view collection containing the key from each key-value pair in this multimap, without collapsing duplicates.
public Set<K>
keySet()

Implements com.google.common.collect.Multimap.keySet.

Returns a view collection of all distinct keys contained in this multimap.
public boolean
put(K key, V value)

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

Stores a key-value pair in this multimap.
public boolean
putAll(K key, Iterable<? extends V> values)

Implements com.google.common.collect.Multimap.putAll.

Stores a key-value pair in this multimap for each of values, all using the same key, key.
public boolean
putAll(Multimap<? extends K, ? extends V> multimap)

Implements com.google.common.collect.Multimap.putAll.

Stores all key-value pairs of multimap in this multimap, in the order returned by multimap.entries().
public boolean
remove(Object key, Object value)

Implements com.google.common.collect.Multimap.remove.

Removes a single key-value pair with the key key and the value value from this multimap, if such exists.
public Collection<V>
replaceValues(K key, Iterable<? extends V> values)

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

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

Returns:

a string representation of the multimap
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the multimap, generated by calling toString on the map returned by Multimap#asMap.
pack-priv Iterator<V>
public Collection<V>
values()

Implements com.google.common.collect.Multimap.values.

Returns a view collection containing the value from each key-value pair contained in this multimap, without collapsing duplicates (so values().size() == size()).
pack-priv Spliterator<V>
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

asMapback to summary
private transient Map<K, Collection<V>> asMap
Annotations
@LazyInit
@CheckForNull
entriesback to summary
private transient Collection<Map.Entry<K, V>> entries
Annotations
@LazyInit
@CheckForNull
keysback to summary
private transient Multiset<K> keys
Annotations
@LazyInit
@CheckForNull
keySetback to summary
private transient Set<K> keySet
Annotations
@LazyInit
@CheckForNull
valuesback to summary
private transient Collection<V> values
Annotations
@LazyInit
@CheckForNull

Constructor Detail

AbstractMultimapback to summary
pack-priv AbstractMultimap()

Method Detail

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

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

Doc from 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. 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.

Annotations
@Override
containsEntryback to summary
public boolean containsEntry(Object key, Object value)

Implements com.google.common.collect.Multimap.containsEntry.

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

Returns true if this multimap contains at least one key-value pair with the key key and the value value.

Annotations
@Override
containsValueback to summary
public boolean containsValue(Object value)

Implements com.google.common.collect.Multimap.containsValue.

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

Returns true if this multimap contains at least one key-value pair with the value value.

Annotations
@Override
createAsMapback to summary
pack-priv abstract Map<K, Collection<V>> createAsMap()
createEntriesback to summary
pack-priv abstract Collection<Map.Entry<K, V>> createEntries()
createKeysback to summary
pack-priv abstract Multiset<K> createKeys()
createKeySetback to summary
pack-priv abstract Set<K> createKeySet()
createValuesback to summary
pack-priv abstract Collection<V> createValues()
entriesback to summary
public Collection<Map.Entry<K, V>> entries()

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

Doc from com.google.common.collect.Multimap.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.

Annotations
@Override
entryIteratorback to summary
pack-priv abstract Iterator<Map.Entry<K, V>> entryIterator()
entrySpliteratorback to summary
pack-priv Spliterator<Map.Entry<K, V>> entrySpliterator()
equalsback to summary
public boolean equals(Object object)

Overrides java.lang.Object.equals.

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

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

Compares the specified object with this multimap for equality. Two multimaps are equal when their map views, as returned by asMap, are also equal.

In general, two multimaps with identical key-value mappings may or may not be equal, depending on the implementation. For example, two SetMultimap instances with the same key-value mappings are equal, but equality of two ListMultimap instances depends on the ordering of the values for each key.

A non-empty SetMultimap cannot be equal to a non-empty ListMultimap, since their asMap views contain unequal collections as values. However, any two empty multimaps are equal, because they both have empty asMap views.

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
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements com.google.common.collect.Multimap.hashCode.

Returns the hash code for this multimap.

The hash code of a multimap is defined as the hash code of the map view, as returned by Multimap#asMap.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
See Also
Map#hashCode
isEmptyback to summary
public boolean isEmpty()

Implements com.google.common.collect.Multimap.isEmpty.

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

Returns true if this multimap contains no key-value pairs. Equivalent to size() == 0, but can in some cases be more efficient.

Annotations
@Override
keysback to summary
public Multiset<K> keys()

Implements com.google.common.collect.Multimap.keys.

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

Returns a view collection containing the key from each key-value pair in this multimap, without collapsing duplicates. This collection has the same size as this multimap, and keys().count(k) == get(k).size() for all k.

Changes to the returned multiset will update the underlying multimap, and vice versa. However, adding to the returned collection is not possible.

Annotations
@Override
keySetback to summary
public Set<K> keySet()

Implements com.google.common.collect.Multimap.keySet.

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

Returns a view collection of all distinct keys contained in this multimap. Note that the key set contains a key if and only if this multimap maps that key to at least one value.

Changes to the returned set will update the underlying multimap, and vice versa. However, adding to the returned set is not possible.

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

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

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

Stores a key-value pair in this multimap.

Some multimap implementations allow duplicate key-value pairs, in which case put always adds a new key-value pair and increases the multimap size by 1. Other implementations prohibit duplicates, and storing a key-value pair that's already in the multimap has no effect.

Returns:boolean

true if the method increased the size of the multimap, or false if the multimap already contained the key-value pair and doesn't allow duplicates

Annotations
@CanIgnoreReturnValue
@Override
putAllback to summary
public boolean putAll(K key, Iterable<? extends V> values)

Implements com.google.common.collect.Multimap.putAll.

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

Stores a key-value pair in this multimap for each of values, all using the same key, key. Equivalent to (but expected to be more efficient than):

for (V value : values) {
  put(key, value);
}

In particular, this is a no-op if values is empty.

Returns:boolean

true if the multimap changed

Annotations
@CanIgnoreReturnValue
@Override
putAllback to summary
public boolean putAll(Multimap<? extends K, ? extends V> multimap)

Implements com.google.common.collect.Multimap.putAll.

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

Stores all key-value pairs of multimap in this multimap, in the order returned by multimap.entries().

Returns:boolean

true if the multimap changed

Annotations
@CanIgnoreReturnValue
@Override
removeback to summary
public boolean remove(Object key, Object value)

Implements com.google.common.collect.Multimap.remove.

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

Removes a single key-value pair with the key key and the value value from this multimap, if such exists. If multiple key-value pairs in the multimap fit this description, which one is removed is unspecified.

Returns:boolean

true if the multimap changed

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

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

Doc from com.google.common.collect.Multimap.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).

Returns:Collection<V>

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
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of the multimap, generated by calling toString on the map returned by Multimap#asMap.

Returns:String

a string representation of the multimap

Annotations
@Override
valueIteratorback to summary
pack-priv Iterator<V> valueIterator()
valuesback to summary
public Collection<V> values()

Implements com.google.common.collect.Multimap.values.

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

Returns a view collection containing the value from each key-value pair contained in this multimap, without collapsing duplicates (so values().size() == size()).

Changes to the returned collection will update the underlying multimap, and vice versa. However, adding to the returned collection is not possible.

Annotations
@Override
valueSpliteratorback to summary
pack-priv Spliterator<V> valueSpliterator()
com.google.common.collect back to summary

pack-priv Class AbstractMultimap.Entries

extends Multimaps.Entries<K extends @Nullable Object, V extends @Nullable Object>
Class Inheritance
Known Direct Subclasses
com.google.common.collect.AbstractMultimap.EntrySet
Annotations
@WeakOuter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Iterator<Map.Entry<K, V>>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Returns an iterator over the elements contained in this collection.
pack-priv Multimap<K, V>
public Spliterator<Map.Entry<K, V>>
spliterator()

Overrides default java.util.Collection.spliterator.

Creates a Spliterator over the elements in this collection.
Inherited from com.google.common.collect.Multimaps.Entries:
clearcontainsremovesize

Constructor Detail

Entriesback to summary
pack-priv Entries()

Method Detail

iteratorback to summary
public Iterator<Map.Entry<K, V>> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Doc from java.util.AbstractCollection.iterator.

Returns an iterator over the elements contained in this collection.

Returns:Iterator<Map.Entry<K, V>>

an iterator over the elements contained in this collection

Annotations
@Override
multimapback to summary
pack-priv Multimap<K, V> multimap()

Implements abstract com.google.common.collect.Multimaps.Entries.multimap.

Annotations
@Override
spliteratorback to summary
public Spliterator<Map.Entry<K, V>> spliterator()

Overrides default java.util.Collection.spliterator.

Doc from java.util.Collection.spliterator.

Creates a Spliterator over the elements in this collection. Implementations should document characteristic values reported by the spliterator. Such characteristic values are not required to be reported if the spliterator reports Spliterator#SIZED and this collection contains no elements.

The default implementation should be overridden by subclasses that can return a more efficient spliterator. In order to preserve expected laziness behavior for the stream() and parallelStream() methods, spliterators should either have the characteristic of IMMUTABLE or CONCURRENT, or be late-binding. If none of these is practical, the overriding class should describe the spliterator's documented policy of binding and structural interference, and should override the stream() and parallelStream() methods to create streams using a Supplier of the spliterator, as in:

Stream<E> s = StreamSupport.stream(() -> spliterator(), spliteratorCharacteristics)

These requirements ensure that streams produced by the stream() and parallelStream() methods will reflect the contents of the collection as of initiation of the terminal stream operation.

Returns:Spliterator<Map.Entry<K, V>>

a Spliterator over the elements in this collection

Annotations
@Override
com.google.common.collect back to summary

pack-priv Class AbstractMultimap.EntrySet

extends AbstractMultimap<K extends @Nullable Object, V extends @Nullable Object>.Entries
implements Set<Map.Entry<K extends @Nullable Object, V extends @Nullable Object>>
Class Inheritance
All Implemented Interfaces
java.util.Set, java.util.Collection, java.lang.Iterable
Annotations
@WeakOuter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
object to be compared for equality with this set
obj
)

Overrides java.lang.Object.equals.

Implements java.util.Set.equals, java.util.Collection.equals.

Compares the specified object with this set for equality.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Set.hashCode, java.util.Collection.hashCode.

Returns the hash code value for this set.
Inherited from com.google.common.collect.AbstractMultimap.Entries:
iteratormultimapspliterator

Constructor Detail

EntrySetback to summary
pack-priv EntrySet()

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Implements java.util.Set.equals, java.util.Collection.equals.

Doc from java.util.Set.equals.

Compares the specified object with this set for equality. Returns true if the specified object is also a set, the two sets have the same size, and every member of the specified set is contained in this set (or equivalently, every member of this set is contained in the specified set). This definition ensures that the equals method works properly across different implementations of the set interface.

Parameters
obj:Object

object to be compared for equality with this set

Returns:boolean

true if the specified object is equal to this set

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Set.hashCode, java.util.Collection.hashCode.

Doc from java.util.Set.hashCode.

Returns the hash code value for this set. The hash code of a set is defined to be the sum of the hash codes of the elements in the set, where the hash code of a null element is defined to be zero. This ensures that s1.equals(s2) implies that s1.hashCode()==s2.hashCode() for any two sets s1 and s2, as required by the general contract of Object#hashCode.

Returns:int

the hash code value for this set

Annotations
@Override
com.google.common.collect back to summary

pack-priv Class AbstractMultimap.Values

extends AbstractCollection<V extends @Nullable Object>
Class Inheritance
Annotations
@WeakOuter

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Collection.clear.

Removes all of the elements from this collection (optional operation).
public boolean
contains(Object
element whose presence in this collection is to be tested
o
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains.

Returns true if this collection contains the specified element.
public Iterator<V>
iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Returns an iterator over the elements contained in this collection.
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Returns the number of elements in this collection.
public Spliterator<V>
spliterator()

Overrides default java.util.Collection.spliterator.

Creates a Spliterator over the elements in this collection.
Inherited from java.util.AbstractCollection:
addaddAllcontainsAllisEmptyremoveremoveAllretainAlltoArraytoArraytoString

Constructor Detail

Valuesback to summary
pack-priv Values()

Method Detail

clearback to summary
public void clear()

Overrides java.util.AbstractCollection.clear.

Implements java.util.Collection.clear.

Doc from java.util.AbstractCollection.clear.

Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.

Annotations
@Override
containsback to summary
public boolean contains(Object o)

Overrides java.util.AbstractCollection.contains.

Implements java.util.Collection.contains.

Doc from java.util.AbstractCollection.contains.

Returns true if this collection contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that Objects.equals(o, e).

Parameters
o:Object

Doc from java.util.Collection.contains.

element whose presence in this collection is to be tested

Returns:boolean

Doc from java.util.Collection.contains.

true if this collection contains the specified element

Annotations
@Override
iteratorback to summary
public Iterator<V> iterator()

Implements abstract java.util.AbstractCollection.iterator.

Implements java.util.Collection.iterator.

Doc from java.util.AbstractCollection.iterator.

Returns an iterator over the elements contained in this collection.

Returns:Iterator<V>

an iterator over the elements contained in this collection

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.Collection.size.

Doc from java.util.Collection.size.

Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this collection

Annotations
@Override
spliteratorback to summary
public Spliterator<V> spliterator()

Overrides default java.util.Collection.spliterator.

Doc from java.util.Collection.spliterator.

Creates a Spliterator over the elements in this collection. Implementations should document characteristic values reported by the spliterator. Such characteristic values are not required to be reported if the spliterator reports Spliterator#SIZED and this collection contains no elements.

The default implementation should be overridden by subclasses that can return a more efficient spliterator. In order to preserve expected laziness behavior for the stream() and parallelStream() methods, spliterators should either have the characteristic of IMMUTABLE or CONCURRENT, or be late-binding. If none of these is practical, the overriding class should describe the spliterator's documented policy of binding and structural interference, and should override the stream() and parallelStream() methods to create streams using a Supplier of the spliterator, as in:

Stream<E> s = StreamSupport.stream(() -> spliterator(), spliteratorCharacteristics)

These requirements ensure that streams produced by the stream() and parallelStream() methods will reflect the contents of the collection as of initiation of the terminal stream operation.

Returns:Spliterator<V>

a Spliterator over the elements in this collection

Annotations
@Override