Class MultiMap<K,V>
java.lang.Object
org.jvnet.hk2.component.MultiMap<K,V>
- Type Parameters:
K- The key of the multi-mapV- The types in the multi-map
- All Implemented Interfaces:
Serializable, Cloneable
Map from a key to multiple values.
Order is significant among values, and null values are allowed, although null keys are not.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPackage private (for getting the raw map for direct manipulation by the habitat)final voidAdds one more key-value pair.clone()Creates a copy of the map that contains the exact same key and value set.booleanChecks if the map contains the given key(s), also extending the search to including the sub collection.booleancontainsKey(K k) Checks if the map contains the given key.entrySet()Lists up all entries.booleanReturns the elements indexed by the provided keyprivate VGets the first value if any, or null.inthashCode()keySet()Returns the set of keys associated with this MultiMapvoidThis method merges all of the keys and values from another MultiMap into this MultiMap.newList(Collection<? extends V> initialVals) Creates an optionally populated list to be used as an entry in the map.Removes an key value from the mapbooleanRemoves an key value pair from the map.voidset(K k, Collection<? extends V> v) Replaces all the existing values associated with the key by the given value.voidReplaces all the existing values associated with the key by the given single value.intsize()Returns the size of the map.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor serialization- See Also:
-
store
-
NEWLINE
-
-
Constructor Details
-
MultiMap
public MultiMap()Creates an empty multi-map with default concurrency controls -
MultiMap
-
-
Method Details
-
newList
Creates an optionally populated list to be used as an entry in the map.- Parameters:
initialVal-- Returns:
-
keySet
-
add
-
set
Replaces all the existing values associated with the key by the given value. If v is empty the key k will be removed from the MultiMap.- Parameters:
k- key for the valuesv- Can be null or empty.
-
set
-
get
-
mergeAll
This method merges all of the keys and values from another MultiMap into this MultiMap. If a key/value pair is found in both MultiMaps it is not re-added to this MultiMap, but is instead discarded- Parameters:
another- The MultiMap from which to add values to this MultiMap. If null this method does nothing
-
_get
-
containsKey
Checks if the map contains the given key.- Parameters:
k- key to test- Returns:
- true if the map contains at least one element for this key
-
contains
-
remove
-
remove
Removes an key value pair from the map. If the list of entries for that key is empty after the remove it will be removed from the set of keys- Parameters:
key- key to be removedentry- the entry to be removed from the key'ed list- Returns:
- true if there was none that was deleted
-
getOne
-
getFirst
-
entrySet
-
toCommaSeparatedString
- Returns:
- the map as "key=value1,key=value2,...."
-
clone
Creates a copy of the map that contains the exact same key and value set. Keys and values won't cloned.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
size
public int size()Returns the size of the map. This returns the numbers of keys in the map, not the number of values- Returns:
- integer or 0 if the map is empty
-
hashCode
-
equals
-
toString
-