Top Description Inners Fields Constructors Methods
org.apache.commons.collections4.multimap

public abstract Class AbstractMultiValuedMap<K, V>

extends Object
implements MultiValuedMap<K, V>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.MultiValuedMap
Known Direct Subclasses
org.apache.commons.collections4.multimap.AbstractSetValuedMap, org.apache.commons.collections4.multimap.AbstractListValuedMap
Type Parameters
<K>
the type of the keys in this map
<V>
the type of the values in this map
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.util.AbstractCollection, .AbstractMap, .AbstractSet, .ArrayList, .Collection, .Iterator, .Map, .Map.Entry, .Set, org.apache.commons.collections4.CollectionUtils, .IteratorUtils, .MapIterator, .MultiSet, .MultiValuedMap, .Transformer, org.apache.commons.collections4.iterators.AbstractIteratorDecorator, .EmptyMapIterator, .IteratorChain, .LazyIteratorChain, .TransformIterator, org.apache.commons.collections4.keyvalue.AbstractMapEntry, .UnmodifiableMapEntry, org.apache.commons.collections4.multiset.AbstractMultiSet, .UnmodifiableMultiSet

Abstract implementation of the MultiValuedMap interface to simplify the creation of subclass implementations.

Subclasses specify a Map implementation to use as the internal storage.

Since
4.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
AbstractMultiValuedMap.AsMap

Inner class that provides the AsMap view.

private class
AbstractMultiValuedMap.EntryValues

Inner class that provides the Entry<k, v> view

private class
AbstractMultiValuedMap.KeysMultiSet

Inner class that provides a MultiSet<k> keys view.

private class
AbstractMultiValuedMap.MultiValuedMapEntry

Inner class for MultiValuedMap Entries.

private class
private class
AbstractMultiValuedMap.Values

Inner class that provides the values view.

private class
AbstractMultiValuedMap.ValuesIterator

Inner class that provides the values iterator.

pack-priv class
AbstractMultiValuedMap.WrappedCollection

Wrapped collection to handle add and remove on the collection returned by get(object).

Field Summary

Modifier and TypeField and Description
private transient AbstractMultiValuedMap<K, V>.AsMap
asMapView

The AsMap view

private transient AbstractMultiValuedMap<K, V>.EntryValues
entryValuesView

The EntryValues view

private transient MultiSet<K>
keysMultiSetView

The KeyMultiSet view

private transient Map<K, Collection<V>>
map

The map used to store the data

private transient Collection<V>
valuesView

The values view

Constructor Summary

AccessConstructor and Description
protected
AbstractMultiValuedMap()

Constructor needed for subclass serialisation.

protected
AbstractMultiValuedMap(final Map<K, ? extends Collection<V>>
the map to wrap, must not be null
map
)

Constructor that wraps (not copies).

Method Summary

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

Implements org.apache.commons.collections4.MultiValuedMap.asMap.

Returns a view of this multi-valued map as a Map from each distinct key to the non-empty collection of that key's associated values.
public void
clear()

Implements org.apache.commons.collections4.MultiValuedMap.clear.

Removes all of the mappings from this map (optional operation).
public boolean
containsKey(final Object
key whose presence in this map is to be tested
key
)

Implements org.apache.commons.collections4.MultiValuedMap.containsKey.

Returns true if this map contains a mapping for the specified key.
public boolean
containsMapping(final Object
the key to search for
key
,
final Object
the value to search for
value
)

Implements org.apache.commons.collections4.MultiValuedMap.containsMapping.

Checks whether the map contains a mapping for the specified key and value.
public boolean
containsValue(final Object
the value to search for
value
)

Implements org.apache.commons.collections4.MultiValuedMap.containsValue.

Checks whether the map contains at least one mapping for the specified value.
protected abstract Collection<V>
protected void
doReadObject(final ObjectInputStream
the input stream
in
)

Read the map in using a custom routine.

protected void
doWriteObject(final ObjectOutputStream
the output stream
out
)

Write the map out using a custom routine.

public Collection<Map.Entry<K, V>>
entries()

Implements org.apache.commons.collections4.MultiValuedMap.entries.

Returns a Collection view of the mappings contained in this multi-valued map.
public boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Collection<V>

Returns:

the Collection of values, will return an empty Collection for no mapping
get
(final K
the key to retrieve
key
)

Implements org.apache.commons.collections4.MultiValuedMap.get.

Gets the collection of values associated with the specified key.
protected Map<K, ? extends Collection<V>>

Returns:

the wrapped map
getMap
()

Gets the map being wrapped.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
isEmpty()

Implements org.apache.commons.collections4.MultiValuedMap.isEmpty.

Returns true if this map contains no key-value mappings.
public MultiSet<K>

Returns:

a bag view of the key mapping contained in this map
keys
()

Implements org.apache.commons.collections4.MultiValuedMap.keys.

Returns a MultiSet view of the key mapping contained in this map.
public Set<K>
keySet()

Implements org.apache.commons.collections4.MultiValuedMap.keySet.

Returns a Set view of the keys contained in this multi-valued map.
public MapIterator<K, V>
mapIterator()

Implements org.apache.commons.collections4.MultiValuedMap.mapIterator.

Obtains a MapIterator over this multi-valued map.
public boolean

Returns:

the value added if the map changed and null if the map did not change
put
(final K
the key to store against
key
,
final V
the value to add to the collection at the key
value
)

Implements org.apache.commons.collections4.MultiValuedMap.put.

Adds the value to the collection associated with the specified key.
public boolean

Returns:

true if the map changed as a result of this operation
putAll
(final Map<? extends K, ? extends V>
mappings to be stored in this map, may not be null
map
)

Implements org.apache.commons.collections4.MultiValuedMap.putAll.

Copies all of the mappings from the specified map to this map.
public boolean

Returns:

true if the map changed as a result of this operation
putAll
(final MultiValuedMap<? extends K, ? extends V>
mappings to be stored in this map, may not be null
map
)

Implements org.apache.commons.collections4.MultiValuedMap.putAll.

Copies all of the mappings from the specified MultiValuedMap to this map.
public boolean

Returns:

true if this map changed
putAll
(final K
the key to store against
key
,
final Iterable<? extends V>
the values to add to the collection at the key, may not be null
values
)

Implements org.apache.commons.collections4.MultiValuedMap.putAll.

Adds Iterable values to the collection associated with the specified key.
public Collection<V>

Returns:

the Collection of values removed, will return an empty, unmodifiable collection for no mapping found
remove
(final Object
the key to remove values from
key
)

Implements org.apache.commons.collections4.MultiValuedMap.remove.

Removes all values associated with the specified key.
public boolean

Returns:

true if the mapping was removed, false otherwise
removeMapping
(final Object
the key to remove from
key
,
final Object
the value to remove
value
)

Implements org.apache.commons.collections4.MultiValuedMap.removeMapping.

Removes a specific key/value mapping from the multi-valued map.
protected void
setMap(final Map<K, ? extends Collection<V>>
the map to wrap
map
)

Sets the map being wrapped.

public int
size()

Implements org.apache.commons.collections4.MultiValuedMap.size.

Gets the total size of the map.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Collection<V>

Returns:

a collection view of the values contained in this map
values
()

Implements org.apache.commons.collections4.MultiValuedMap.values.

Gets a collection containing all the values in the map.
pack-priv Collection<V>
wrappedCollection(final K key)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait