public class TwoDimensionalCollectionValuedMap<K1,K2,V>
extends java.lang.Object
implements java.io.Serializable
Collection
s of Object values.
Important methods are the add(K1, K2, V)
and for adding a value
to/from the Collection associated with the key, and the get(K1, K2)
method for
getting the Collection associated with a key.
The class is quite general, because on construction, it is possible to pass a MapFactory
which will be used to create the underlying map and a CollectionFactory
which will
be used to create the Collections. Thus this class can be configured to act like a "HashSetValuedMap"
or a "ListValuedMap", or even a "HashSetValuedIdentityHashMap". The possibilities are endless!Modifier and Type | Field and Description |
---|---|
protected CollectionFactory<V> |
cf |
protected MapFactory<K2,java.util.Collection<V>> |
mf |
Constructor and Description |
---|
TwoDimensionalCollectionValuedMap()
Creates a new empty TwoDimensionalCollectionValuedMap which uses a HashMap as the
underlying Map, and HashSets as the Collections in each mapping.
|
TwoDimensionalCollectionValuedMap(boolean treatCollectionsAsImmutable)
Creates a new empty TwoDimensionalCollectionValuedMap which uses a HashMap as the
underlying Map, and HashSets as the Collections in each mapping.
|
TwoDimensionalCollectionValuedMap(CollectionFactory<V> cf)
Creates a new empty TwoDimensionalCollectionValuedMap which uses a HashMap as the
underlying Map.
|
TwoDimensionalCollectionValuedMap(MapFactory<K2,java.util.Collection<V>> mf,
CollectionFactory<V> cf)
Creates a new empty TwoDimensionalCollectionValuedMap.
|
TwoDimensionalCollectionValuedMap(MapFactory<K2,java.util.Collection<V>> mf,
CollectionFactory<V> cf,
boolean treatCollectionsAsImmutable)
Creates a new empty TwoDimensionalCollectionValuedMap.
|
Modifier and Type | Method and Description |
---|---|
void |
add(K1 key1,
K2 key2,
java.util.Collection<V> value)
Adds a collection of values to the Collection mapped to by the key.
|
void |
add(K1 key1,
K2 key2,
V value)
Adds the value to the Collection mapped to by the key.
|
void |
addKey(K1 key1)
yes, this is a weird method, but i need it.
|
void |
clear() |
boolean |
containsKey(K1 key) |
java.util.Set<java.util.Map.Entry<K1,CollectionValuedMap<K2,V>>> |
entrySet() |
java.util.Set<K1> |
firstKeySet() |
java.util.Collection<V> |
get(K1 key1,
K2 key2) |
CollectionValuedMap<K2,V> |
getCollectionValuedMap(K1 key1) |
java.util.Set<K1> |
keySet() |
void |
putAll(java.util.Map<K1,CollectionValuedMap<K2,V>> toAdd) |
void |
retainAll(java.util.Set<K1> keys) |
java.util.Set<K2> |
secondKeySet() |
java.lang.String |
toString() |
java.util.Collection<V> |
values() |
protected MapFactory<K2,java.util.Collection<V>> mf
protected CollectionFactory<V> cf
public TwoDimensionalCollectionValuedMap()
public TwoDimensionalCollectionValuedMap(boolean treatCollectionsAsImmutable)
treatCollectionsAsImmutable
- whether or not to treat collections as immutablepublic TwoDimensionalCollectionValuedMap(CollectionFactory<V> cf)
cf
- a CollectionFactory which will be used to generate the
Collections in each mappingpublic TwoDimensionalCollectionValuedMap(MapFactory<K2,java.util.Collection<V>> mf, CollectionFactory<V> cf)
mf
- a MapFactory which will be used to generate the underlying Mapcf
- a CollectionFactory which will be used to generate the Collections in each mappingpublic TwoDimensionalCollectionValuedMap(MapFactory<K2,java.util.Collection<V>> mf, CollectionFactory<V> cf, boolean treatCollectionsAsImmutable)
mf
- a MapFactory which will be used to generate the underlying Mapcf
- a CollectionFactory which will be used to generate the Collections in each mappingtreatCollectionsAsImmutable
- if true, forces this Map to create new a Collection everytime
a new value is added to or deleted from the Collection a mapping.public java.lang.String toString()
toString
in class java.lang.Object
public void putAll(java.util.Map<K1,CollectionValuedMap<K2,V>> toAdd)
public CollectionValuedMap<K2,V> getCollectionValuedMap(K1 key1)
public void add(K1 key1, K2 key2, V value)
public void add(K1 key1, K2 key2, java.util.Collection<V> value)
public void addKey(K1 key1)
public void clear()
public java.util.Set<K1> keySet()
public java.util.Set<java.util.Map.Entry<K1,CollectionValuedMap<K2,V>>> entrySet()
public boolean containsKey(K1 key)
public void retainAll(java.util.Set<K1> keys)
public java.util.Set<K1> firstKeySet()
public java.util.Set<K2> secondKeySet()
public java.util.Collection<V> values()