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

public abstract Class AbstractSetValuedMap<K, V>

extends AbstractMultiValuedMap<K, V>
implements SetValuedMap<K, V>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.SetValuedMap, org.apache.commons.collections4.MultiValuedMap
Known Direct Subclasses
org.apache.commons.collections4.multimap.HashSetValuedHashMap
Type Parameters
<K>
the type of the keys in this map
<V>
the type of the values in this map
Imports
java.util.Collections, .Map, .Set, org.apache.commons.collections4.SetUtils, .SetValuedMap

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

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

Since
4.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
AbstractSetValuedMap.WrappedSet

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

Constructor Summary

AccessConstructor and Description
protected
AbstractSetValuedMap()

Constructor needed for subclass serialisation.

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

A constructor that wraps, not copies

Method Summary

Modifier and TypeMethod and Description
protected abstract Set<V>

Returns:

a new list
createCollection
()

Implements abstract org.apache.commons.collections4.multimap.AbstractMultiValuedMap.createCollection.

Creates a new value collection using the provided factory.
public Set<V>

Returns:

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

Overrides org.apache.commons.collections4.multimap.AbstractMultiValuedMap.get.

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

Gets the set of values associated with the specified key.
protected Map<K, Set<V>>
public Set<V>

Returns:

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

Overrides org.apache.commons.collections4.multimap.AbstractMultiValuedMap.remove.

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

Removes all values associated with the specified key.
pack-priv Set<V>
Inherited from org.apache.commons.collections4.multimap.AbstractMultiValuedMap:
asMapclearcontainsKeycontainsMappingcontainsValuedoReadObjectdoWriteObjectentriesequalshashCodeisEmptykeyskeySetmapIteratorputputAllputAllputAllremoveMappingsetMapsizetoStringvalues

Constructor Detail

AbstractSetValuedMapback to summary
protected AbstractSetValuedMap()

Constructor needed for subclass serialisation.

AbstractSetValuedMapback to summary
protected AbstractSetValuedMap(final Map<K, ? extends Set<V>> map)

A constructor that wraps, not copies

Parameters
map:Map<K, ? extends Set<V>>

the map to wrap, must not be null

Exceptions
NullPointerException:
if the map is null

Method Detail

createCollectionback to summary
protected abstract Set<V> createCollection()

Implements abstract org.apache.commons.collections4.multimap.AbstractMultiValuedMap.createCollection.

Creates a new value collection using the provided factory.

Returns:Set<V>

a new list

Annotations
@Override
getback to summary
public Set<V> get(final K key)

Overrides org.apache.commons.collections4.multimap.AbstractMultiValuedMap.get.

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

Gets the set of values associated with the specified key. This would return an empty set in case the mapping is not present

Parameters
key:K

the key to retrieve

Returns:Set<V>

the Set of values, will return an empty Set for no mapping

Annotations
@Override
getMapback to summary
protected Map<K, Set<V>> getMap()

Overrides org.apache.commons.collections4.multimap.AbstractMultiValuedMap.getMap.

Doc from org.apache.commons.collections4.multimap.AbstractMultiValuedMap.getMap.

Gets the map being wrapped.

Returns:Map<K, Set<V>>

the wrapped map

Annotations
@Override
@SuppressWarnings:unchecked
removeback to summary
public Set<V> remove(final Object key)

Overrides org.apache.commons.collections4.multimap.AbstractMultiValuedMap.remove.

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

Removes all values associated with the specified key.

A subsequent get(Object) would return an empty set.

Parameters
key:Object

the key to remove values from

Returns:Set<V>

the Set of values removed, will return an empty, unmodifiable set for no mapping found.

Annotations
@Override
wrappedCollectionback to summary
pack-priv Set<V> wrappedCollection(final K key)

Overrides org.apache.commons.collections4.multimap.AbstractMultiValuedMap.wrappedCollection.

Annotations
@Override
org.apache.commons.collections4.multimap back to summary

private Class AbstractSetValuedMap.WrappedSet

extends AbstractMultiValuedMap<K, V>.WrappedCollection
implements Set<V>
Class Inheritance
All Implemented Interfaces
java.util.Set, java.util.Collection, java.lang.Iterable

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

Field Summary

Inherited from org.apache.commons.collections4.multimap.AbstractMultiValuedMap.WrappedCollection:
key

Constructor Summary

AccessConstructor and Description
public
WrappedSet(final K key)

Method Summary

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

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 org.apache.commons.collections4.multimap.AbstractMultiValuedMap.WrappedCollection:
addaddAllclearcontainscontainsAllgetMappingisEmptyiteratorremoveremoveAllretainAllsizetoArraytoArraytoString

Constructor Detail

WrappedSetback to summary
public WrappedSet(final K key)

Method Detail

equalsback to summary
public boolean equals(final Object other)

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
other: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