Package org.alfresco.util
Class OneToManyHashBiMap<K,V>
- java.lang.Object
-
- org.alfresco.util.OneToManyHashBiMap<K,V>
-
- All Implemented Interfaces:
Map<K,Set<V>>,OneToManyBiMap<K,V>,OneToManyMap<K,V>
public class OneToManyHashBiMap<K,V> extends Object implements Map<K,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 voidclear()booleancontainsKey(Object key)booleancontainsSingleValue(V value)This method returnstrueif any of the value sets in the OneToManyMap contains an equivalent object to thevalueparameter, where equivalence is determined using theequals(Object)method.booleancontainsValue(Object value)Set<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>).Set<Map.Entry<K,Set<V>>>entrySet()Collection<V>flatValues()Returns a Collection of all the values in the map.Set<V>get(Object key)KgetKey(V value)Returns the key, if any, for the specifiedvalue.booleanisEmpty()Set<K>keySet()Set<V>put(K key, Set<V> values)voidputAll(Map<? extends K,? extends Set<V>> m)voidputAllSingleValues(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.VputSingleValue(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.Setcontaining one or more values.Set<V>remove(Object key)KremoveValue(V value)Removes the specifiedvaluefrom theOneToManyBiMap.intsize()Collection<Set<V>>values()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
containsSingleValue
public boolean containsSingleValue(V value)
Description copied from interface:OneToManyMapThis method returnstrueif any of the value sets in the OneToManyMap contains an equivalent object to thevalueparameter, where equivalence is determined using theequals(Object)method.- Specified by:
containsSingleValuein interfaceOneToManyMap<K,V>- Parameters:
value- The value being searched for.- Returns:
- Returns
trueif any of the value sets contains a matching value, otherwise returnsfalse
-
entries
public Set<Map.Entry<K,V>> entries()
Description copied from interface:OneToManyMapThis 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:
entriesin interfaceOneToManyMap<K,V>- Returns:
- The
Set<Entry<K, V>> representing all the key-value pairs in the ManyToOneMap.
-
getKey
public K getKey(V value)
Description copied from interface:OneToManyBiMapReturns the key, if any, for the specifiedvalue. If the specified value does not exist within the map then this method returnsnull.- Specified by:
getKeyin interfaceOneToManyBiMap<K,V>- Returns:
- The key to the specified
valueornull.
-
putSingleValue
public V putSingleValue(K key, V value)
Description copied from interface:OneToManyMapThis 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.Setcontaining 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:
putSingleValuein interfaceOneToManyMap<K,V>- Returns:
- returns the newly added value.
-
putAllSingleValues
public void putAllSingleValues(Map<? extends K,? extends V> m)
Description copied from interface:OneToManyMapThis 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:
putAllSingleValuesin interfaceOneToManyMap<K,V>- Parameters:
m- A map containing the key-value mappings to be added to the ManyToOneMap.
-
removeValue
public K removeValue(V value)
Description copied from interface:OneToManyBiMapRemoves the specifiedvaluefrom theOneToManyBiMap. If this was the only value associated with the key to this value, then the key is also removed.- Specified by:
removeValuein interfaceOneToManyBiMap<K,V>- Parameters:
value- The value to be removed.- Returns:
- The key that is associated with the value to be removed.
-
flatValues
public Collection<V> flatValues()
Description copied from interface:OneToManyMapReturns 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:
flatValuesin interfaceOneToManyMap<K,V>- Returns:
- All the values in the map as a flattened Collection.
-
-