Package org.alfresco.util
Class OneToManyHashBiMap<K,V>
- java.lang.Object
-
- org.alfresco.util.OneToManyHashBiMap<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,java.util.Set<V>>
,OneToManyBiMap<K,V>
,OneToManyMap<K,V>
public class OneToManyHashBiMap<K,V> extends java.lang.Object implements java.util.Map<K,java.util.Set<V>>, OneToManyBiMap<K,V>
- Author:
- Nick Smith
-
-
Constructor Summary
Constructors Constructor Description OneToManyHashBiMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(java.lang.Object key)
boolean
containsSingleValue(V value)
This method returnstrue
if any of the value sets in the OneToManyMap contains an equivalent object to thevalue
parameter, where equivalence is determined using theequals(Object)
method.boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<K,V>>
entries()
This method is similar to thejava.util.Map.entrySet()
method, however the entries returned map from a key to a value, rather than from a key(K
) to a value(V
) rather than froma key(K
) to a set of values(Set<V>
).java.util.Set<java.util.Map.Entry<K,java.util.Set<V>>>
entrySet()
java.util.Collection<V>
flatValues()
Returns a Collection of all the values in the map.java.util.Set<V>
get(java.lang.Object key)
K
getKey(V value)
Returns the key, if any, for the specifiedvalue
.boolean
isEmpty()
java.util.Set<K>
keySet()
java.util.Set<V>
put(K key, java.util.Set<V> values)
void
putAll(java.util.Map<? extends K,? extends java.util.Set<V>> m)
void
putAllSingleValues(java.util.Map<? extends K,? extends V> m)
This method is similar tojava.utilMap.putAll(Map m)
, however the map specified is from keys to values instead of keys to sets of values.V
putSingleValue(K key, V value)
This method is similar to the methodjava.util.Map.put(K, V)
, however it allows the user to add a single value to the map rather than adding ajava.util.Set
containing one or more values.java.util.Set<V>
remove(java.lang.Object key)
K
removeValue(V value)
Removes the specifiedvalue
from theOneToManyBiMap
.int
size()
java.util.Collection<java.util.Set<V>>
values()
-
-
-
Method Detail
-
containsKey
public boolean containsKey(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
containsSingleValue
public boolean containsSingleValue(V value)
Description copied from interface:OneToManyMap
This method returnstrue
if any of the value sets in the OneToManyMap contains an equivalent object to thevalue
parameter, where equivalence is determined using theequals(Object)
method.- Specified by:
containsSingleValue
in interfaceOneToManyMap<K,V>
- Parameters:
value
- The value being searched for.- Returns:
- Returns
true
if any of the value sets contains a matching value, otherwise returnsfalse
-
entries
public java.util.Set<java.util.Map.Entry<K,V>> entries()
Description copied from interface:OneToManyMap
This method is similar to thejava.util.Map.entrySet()
method, however the entries returned map from a key to a value, rather than from a key(K
) to a value(V
) rather than froma key(K
) to a set of values(Set<V>
).
Note that the entries returned by this method do not support the methodjava.util.Map.Entry.setValue(V)
.- Specified by:
entries
in interfaceOneToManyMap<K,V>
- Returns:
- The
Set<Entry<K, V>> representing all the key-value pairs in the ManyToOneMap.
-
get
public java.util.Set<V> get(java.lang.Object key)
-
getKey
public K getKey(V value)
Description copied from interface:OneToManyBiMap
Returns the key, if any, for the specifiedvalue
. If the specified value does not exist within the map then this method returnsnull
.- Specified by:
getKey
in interfaceOneToManyBiMap<K,V>
- Returns:
- The key to the specified
value
ornull
.
-
putSingleValue
public V putSingleValue(K key, V value)
Description copied from interface:OneToManyMap
This method is similar to the methodjava.util.Map.put(K, V)
, however it allows the user to add a single value to the map rather than adding ajava.util.Set
containing one or more values. If the specified key already has a set of values associated with it then the new value is added to this set. Otherwise a new set is created and the new value is added to that.- Specified by:
putSingleValue
in interfaceOneToManyMap<K,V>
- Returns:
- returns the newly added value.
-
putAllSingleValues
public void putAllSingleValues(java.util.Map<? extends K,? extends V> m)
Description copied from interface:OneToManyMap
This method is similar tojava.utilMap.putAll(Map m)
, however the map specified is from keys to values instead of keys to sets of values.- Specified by:
putAllSingleValues
in interfaceOneToManyMap<K,V>
- Parameters:
m
- A map containing the key-value mappings to be added to the ManyToOneMap.
-
remove
public java.util.Set<V> remove(java.lang.Object key)
-
removeValue
public K removeValue(V value)
Description copied from interface:OneToManyBiMap
Removes the specifiedvalue
from theOneToManyBiMap
. If this was the only value associated with the key to this value, then the key is also removed.- Specified by:
removeValue
in interfaceOneToManyBiMap<K,V>
- Parameters:
value
- The value to be removed.- Returns:
- The key that is associated with the value to be removed.
-
values
public java.util.Collection<java.util.Set<V>> values()
-
flatValues
public java.util.Collection<V> flatValues()
Description copied from interface:OneToManyMap
Returns a Collection of all the values in the map. Unlikevalues()
the values are in a single flattenedCollection<V>
rather than aCollection<Set<V>>
.- Specified by:
flatValues
in interfaceOneToManyMap<K,V>
- Returns:
- All the values in the map as a flattened Collection.
-
-