Package org.datanucleus.util
Class MultiMap
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap
-
- org.datanucleus.util.MultiMap
-
- All Implemented Interfaces:
Serializable,Cloneable,Map
public class MultiMap extends HashMap
An implementation of aMultiMap, which is basically a Map with multiple values for a key. This will be removed when SUN see sense and include it in the JDK java.util package as standard.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clear the map.Objectclone()Method to clone the Map.booleancontainsValue(Object value)Check if the map contains the passed value.protected CollectioncreateCollection(Collection c)Creates a new instance of the map value Collection container.Objectput(Object key, Object value)Add a key, and its value, to the map.ObjectremoveKeyValue(Object key, Object item)Removes a specific key,value pairing from map.Collectionvalues()Accessor for the values in the Map.-
Methods inherited from class java.util.HashMap
compute, computeIfAbsent, computeIfPresent, containsKey, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Constructor Detail
-
MultiMap
public MultiMap()
Constructor.
-
MultiMap
public MultiMap(int initialCapacity)
Constructor.- Parameters:
initialCapacity- the initial capacity
-
MultiMap
public MultiMap(int initialCapacity, float loadFactor)Constructor.- Parameters:
initialCapacity- initial capacityloadFactor- load factor for the Map.
-
MultiMap
public MultiMap(MultiMap map)
Constructor.- Parameters:
map- The initial Map.
-
-
Method Detail
-
containsValue
public boolean containsValue(Object value)
Check if the map contains the passed value.- Specified by:
containsValuein interfaceMap- Overrides:
containsValuein classHashMap- Parameters:
value- the value to search for- Returns:
- true if the list contains the value
-
removeKeyValue
public Object removeKeyValue(Object key, Object item)
Removes a specific key,value pairing from map. The item is removed from the collection mapped to the specified key.- Parameters:
key- the key to remove fromitem- the value to remove- Returns:
- the value removed (which was passed in)
-
clear
public void clear()
Clear the map.
-
values
public Collection values()
Accessor for the values in the Map.
-
clone
public Object clone()
Method to clone the Map. Performs a shallow copy of the entry set.
-
createCollection
protected Collection createCollection(Collection c)
Creates a new instance of the map value Collection container.- Parameters:
c- the collection to copy- Returns:
- new collection
-
-