Class MultivaluedMapUtils

java.lang.Object
com.nimbusds.oauth2.sdk.util.MultivaluedMapUtils

public final class MultivaluedMapUtils extends Object
Multi-valued map utilities.
  • Method Details

    • toSingleValuedMap

      public static <K, V> Map<K,V> toSingleValuedMap(Map<K,List<V>> map)
      Converts the specified multi-valued map to a single-valued map by taking the first value in the list.
      Parameters:
      map - The multi-valued map, null if not specified.
      Returns:
      The single-valued map, null if no map was specified.
    • getFirstValue

      public static <K, V> V getFirstValue(Map<K,List<V>> map, K key)
      Gets the first value for the specified key.
      Parameters:
      map - The multi-valued map. Must not be null.
      key - The key. Must not be null.
      Returns:
      The first value, null if not set.
    • removeAndReturnFirstValue

      public static <K, V> V removeAndReturnFirstValue(Map<K,List<V>> map, String key)
      Removes the entry for the specified key and returns its first value.
      Parameters:
      map - The multi-valued map. Must not be null.
      key - The key. Must not be null.
      Returns:
      The first value, null if not set.
    • getKeysWithMoreThanOneValue

      public static <K, V> Set<K> getKeysWithMoreThanOneValue(Map<K,List<V>> map, Set<K> excepted)
      Returns the keys with more than one distinct value. Keys that map to two or more identical values are treated as single-valued.
      Parameters:
      map - The multi-valued map, null if not specified.
      excepted - The excepted keys, null or empty if none.
      Returns:
      The keys with more than one distinct value, empty set if none.