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 type
V - Value type (of the list)
All Implemented Interfaces:
Map<K,List<V>>
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.
  • Constructor Details

    • MultiValueMap

      public MultiValueMap(Map<K,List<V>> map)
      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

      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, or null 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

      public 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.
      Parameters:
      key - key with which the specified value is to be mapped.
      value - the single value to be mapped to the specified key.