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
public class MultiValueMap<K,V> extends MapDecorator<K,List<V>>
Wraps a map for which the values are lists, providing a set of convenience methods for handling list values.
-
-
Field Summary
-
Fields inherited from class org.forgerock.util.MapDecorator
map
-
-
Constructor Summary
Constructors Constructor Description MultiValueMap(Map<K,List<V>> map)
Creates a new multi-value map, wrapping an existing map with list values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(K key, V value)
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.V
getFirst(K key)
Returns the first value in the list of values for the matching key, ornull
if no such value exists.void
putSingle(K key, V value)
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
-
-
-
-
Method Detail
-
add
public void add(K key, V value)
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
public void addAll(K key, Collection<? extends V> values)
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
public void addAll(MultiValueMap<K,V> map)
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
public void addAll(Map<? extends K,Collection<? extends V>> map)
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
public V getFirst(K key)
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.
-
-