Class AbstractMapBasedMultimap.WrappedCollection

java.lang.Object
java.util.AbstractCollection<V>
com.google.common.collect.AbstractMapBasedMultimap.WrappedCollection
All Implemented Interfaces:
Iterable<V>, Collection<V>
Direct Known Subclasses:
AbstractMapBasedMultimap.WrappedList, AbstractMapBasedMultimap.WrappedSet, AbstractMapBasedMultimap.WrappedSortedSet
Enclosing class:
AbstractMapBasedMultimap<K,V>

class AbstractMapBasedMultimap.WrappedCollection extends AbstractCollection<V>
Collection decorator that stays in sync with the multimap values for a key. There are two kinds of wrapped collections: full and subcollections. Both have a delegate pointing to the underlying collection class.

Full collections, identified by a null ancestor field, contain all multimap values for a given key. Its delegate is a value in AbstractMapBasedMultimap.map whenever the delegate is non-empty. The refreshIfEmpty, removeIfEmpty, and addToMap methods ensure that the WrappedCollection and map remain consistent.

A subcollection, such as a sublist, contains some of the values for a given key. Its ancestor field points to the full wrapped collection with all values for the key. The subcollection refreshIfEmpty, removeIfEmpty, and addToMap methods call the corresponding methods of the full wrapped collection.