Package ratpack.func

Interface MultiValueMap<K,​V>

  • Type Parameters:
    K - The type of key objects
    V - The type of value objects
    All Superinterfaces:
    Map<K,​V>
    All Known Subinterfaces:
    Form

    public interface MultiValueMap<K,​V>
    extends Map<K,​V>
    A map that may contain multiple values for a given key, but typically only one value.

    Unlike other multi map types, this type is optimized for the case where there is only one value for a key. The map acts just like a normal Map, but has extra methods for getting all values for a key.

    All implementations of this type are immutable. Mutating operations throw UnsupportedOperationException.

    Where there is multiple values for a given key, retrieving a single value will return the first value, where the first value is intrinsic to the service in which the map is being used.

    • Method Detail

      • getAll

        List<V> getAll​(K key)
        All of the values for the given key. An empty list if there are no values for the key.

        The returned list is immutable.

        Parameters:
        key - The key to return all values of
        Returns:
        all of the values for the given key, or an empty list if there are no values for the key.
      • getAll

        Map<K,​List<V>> getAll()
        Returns a new view of the map where each map value is a list of all the values for the given key (i.e. a traditional multi map).

        The returned map is immutable.

        Returns:
        A new view of the map where each map value is a list of all the values for the given key
      • get

        @Nullable
        V get​(Object key)
        Get the first value for the key, or null if there are no values for the key.
        Specified by:
        get in interface Map<K,​V>
        Parameters:
        key - The key to obtain the first value for
        Returns:
        The first value for the given key, or null if there are no values for the given key
      • asMultimap

        com.google.common.collect.ListMultimap<K,​V> asMultimap()