K1
- The Class of the primary key for this DoubleKeyMapK2
- The Class of the secondary key for this DoubleKeyMapV
- The Class of the Value for this DoubleKeyMappublic class DoubleKeyMap<K1,K2,V>
extends java.lang.Object
implements java.lang.Cloneable
Constructor and Description |
---|
DoubleKeyMap()
Creates a new, empty DoubleKeyMap using HashMap as the underlying Map
class for both the primary and secondary underlying Map.
|
DoubleKeyMap(java.lang.Class<? extends java.util.Map> cl1,
java.lang.Class<? extends java.util.Map> cl2)
Creates a new, empty DoubleKeyMap using the given classes as the
underlying Map classes for the primary and secondary underlying Maps.
|
DoubleKeyMap(DoubleKeyMap<K1,K2,V> otherMap)
Constructs a new DoubleKeyMap with the same mappings and underlying
classes as the given DoubleKeyMap.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this DoubleKeyMap.
|
DoubleKeyMap<K1,K2,V> |
clone()
Produces a clone of the DoubleKeyMap.
|
boolean |
containsKey(K1 key1)
Returns true if the DoubleKeyMap contains a map stored under the given
primary key.
|
boolean |
containsKey(K1 key1,
K2 key2)
Returns true if the DoubleKeyMap contains a value for the given keys.
|
boolean |
equals(java.lang.Object obj)
Returns true if the DoubleKeyMap is equal to the given Object.
|
V |
get(K1 key1,
K2 key2)
Get the value from DoubleKeyMap for the given keys.
|
java.util.Set<K1> |
getKeySet()
Returns a Set of the primary keys for this DoubleKeyMap.
|
java.util.Map<K2,V> |
getMapFor(K1 key1)
Retrieves the Map from DoubleKeyMap for the given primary key.
|
java.util.Map<K2,V> |
getReadOnlyMapFor(K1 key1)
Returns a read-only map containing the submap for the primary key in this
DoubleKeyMap.
|
java.util.Set<K2> |
getSecondaryKeySet(K1 key1)
Returns a Set of the secondary keys for the given primary key in this
DoubleKeyMap
Note: This Set is reference-semantic.
|
int |
hashCode()
A consistent-with-equals hashCode for DoubleKeyMap.
|
boolean |
isEmpty()
Returns true if the DoubleKeyMap is empty; false otherwise
Note: This method evaluates information stored under any primary and
secondary key OR a previous call to getReadOnlyMapFor(K1) for any primary
key [and no subsequent call to remove(K1) or clear()].
|
int |
primaryKeyCount()
Returns the number of primary keys in this DoubleKeyMap
Note: This method evaluates information stored under any primary and
secondary key OR a previous call to getReadOnlyMapFor(K1) for any primary
key [and no subsequent call to remove(K1) or clear()].
|
V |
put(K1 key1,
K2 key2,
V value)
Put the given value into this DoubleKeyMap for the given keys.
|
void |
putAll(DoubleKeyMap<K1,K2,V> dkm)
Copies the key/value combinations from the given DoubleKeyMap into this
DoubleKeyMap.
|
V |
remove(K1 key1,
K2 key2)
Removes the value from DoubleKeyMap for the given keys and returns the
value that was removed from the DoubleKeyMap.
|
java.util.Map<K2,V> |
removeAll(K1 key1)
Removes all objects with the given primary key from the DoubleKeyMap.
|
boolean |
removeValue(K1 key1,
V obj)
Removes the given value from DoubleKeyMap for the given primary key.
|
java.util.Set<V> |
values(K1 key1)
Returns a Set of the values stored in this DoubleKeyMap for the given
primary key.
|
public DoubleKeyMap()
public DoubleKeyMap(java.lang.Class<? extends java.util.Map> cl1, java.lang.Class<? extends java.util.Map> cl2)
cl1
- The Class to be used for the primary underlying mapcl2
- The Class to be used for the secondary underlying mapjava.lang.IllegalArgumentException
- if one or both of the given Classes is null or does not have
a public, zero argument constructor.public DoubleKeyMap(DoubleKeyMap<K1,K2,V> otherMap)
otherMap
- The DoubleKeyMap to use as a source of mappings for
initializing this DoubleKeyMapjava.lang.NullPointerException
- if the given DoubleKeyMap is nullpublic V put(K1 key1, K2 key2, V value)
key1
- The primary key for storing the given valuekey2
- The secondary key for storing the given valuevalue
- The value to be stored for the given keyspublic final void putAll(DoubleKeyMap<K1,K2,V> dkm)
dkm
- The DoubleKeyMap for which the key/value combinations should
be placed into this DoubleKeyMapjava.lang.NullPointerException
- if the given DoubleKeyMap is nullpublic V get(K1 key1, K2 key2)
key1
- The primary key for retrieving the given valuekey2
- The secondary key for retrieving the given valuepublic java.util.Map<K2,V> getMapFor(K1 key1)
key1
- The primary key for retrieving the mappublic boolean containsKey(K1 key1)
key1
- The primary key for retrieving the given valuepublic boolean containsKey(K1 key1, K2 key2)
key1
- The primary key for retrieving the given valuekey2
- The secondary key for retrieving the given valuepublic V remove(K1 key1, K2 key2)
key1
- The primary key for retrieving the given valuekey2
- The secondary key for retrieving the given valuepublic java.util.Map<K2,V> removeAll(K1 key1)
key1
- The primary key used to remove the value in this DoubleKeyMap.public java.util.Set<K1> getKeySet()
public java.util.Set<K2> getSecondaryKeySet(K1 key1)
key1
- The primary key to retrieve keys for.public void clear()
public java.util.Set<V> values(K1 key1)
key1
- The primary key for which the values will be returnedpublic boolean isEmpty()
public int primaryKeyCount()
public DoubleKeyMap<K1,K2,V> clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- (should not be thrown)Object.clone()
public boolean removeValue(K1 key1, V obj)
key1
- The primary key for removing the given valueobj
- The object stored under the given primary key (and any
secondary key) to be removed from the DoubleKeyMap.public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public java.util.Map<K2,V> getReadOnlyMapFor(K1 key1)
key1
- The primary key for which the submap in this DoubleKeyMap
should be returned