Package org.alfresco.util
Class OneToManyHashMap<K,V>
java.lang.Object
org.alfresco.util.OneToManyHashMap<K,V>
- All Implemented Interfaces:
Map<K,
,Set<V>> OneToManyMap<K,
V>
- Author:
- Nick Smith
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(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
(Object value) 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>
).entrySet()
Returns a Collection of all the values in the map.boolean
isEmpty()
keySet()
void
void
putAllSingleValues
(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.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.int
size()
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
-
Constructor Details
-
OneToManyHashMap
public OneToManyHashMap()
-
-
Method Details
-
clear
public void clear() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
containsSingleValue
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
-
entrySet
-
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
-
isEmpty
public boolean isEmpty() -
keySet
-
put
-
putSingleValue
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.
-
putAll
-
putAllSingleValues
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
-
size
public int size() -
values
-
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.
-