Package org.forgerock.http.util
Class MultiValueMap<K,V>
java.lang.Object
org.forgerock.util.MapDecorator<K,List<V>>
org.forgerock.http.util.MultiValueMap<K,V>
- Type Parameters:
K
- Key typeV
- Value type (of the list)
- Direct Known Subclasses:
Form
Wraps a map for which the values are lists, providing a set of convenience methods for
handling list values.
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.forgerock.util.MapDecorator
map
-
Constructor Summary
ConstructorDescriptionMultiValueMap
(Map<K, List<V>> map) Creates a new multi-value map, wrapping an existing map with list values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the specified value to the list for the specified key.void
addAll
(Map<? extends K, Collection<? extends V>> map) Adds the specified keys and values from the specified map into this map.void
addAll
(K key, Collection<? extends V> values) Adds the specified values to the list for the specified key.void
addAll
(MultiValueMap<K, V> map) Adds the specified keys and values from the specified map into this map.Returns the first value in the list of values for the matching key, ornull
if no such value exists.void
Maps a single value to the specified key, replacing any value(s) that are already mapped to that key.Methods inherited from class org.forgerock.util.MapDecorator
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
MultiValueMap
Creates a new multi-value map, wrapping an existing map with list values.- Parameters:
map
- the map to wrap with a new multi-value map.
-
-
Method Details
-
add
Adds the specified value to the list for the specified key. If no list for the key yet exists in the map, a new list is created and added.- Parameters:
key
- the key of the list to add the value to.value
- the value to be added to the list.
-
addAll
Adds the specified values to the list for the specified key. If no list for the key yet exists in the map, a new list is created and added.- Parameters:
key
- the key of the list to add the values to.values
- the values to be added to the list.
-
addAll
Adds the specified keys and values from the specified map into this map.- Parameters:
map
- the map whose keys and values are to be added.
-
addAll
Adds the specified keys and values from the specified map into this map.- Parameters:
map
- the map whose keys and values are to be added.
-
getFirst
Returns the first value in the list of values for the matching key, ornull
if no such value exists.- Parameters:
key
- the key whose associated first item is to be returned.- Returns:
- the first value in the key's value list, or null if non-existent.
-
putSingle
Maps a single value to the specified key, replacing any value(s) that are already mapped to that key.- Parameters:
key
- key with which the specified value is to be mapped.value
- the single value to be mapped to the specified key.
-