Interface MapValue.Immutable<K,​V>

  • Type Parameters:
    K - The type of the key
    V - The type of the value
    All Superinterfaces:
    MapValue<K,​V>, Value<java.util.Map<K,​V>>, Value.Immutable<java.util.Map<K,​V>>
    Enclosing interface:
    MapValue<K,​V>

    public static interface MapValue.Immutable<K,​V>
    extends MapValue<K,​V>, Value.Immutable<java.util.Map<K,​V>>
    Represents a specialized type of Value.Immutable that is different from an CollectionValue.Immutable such that the "elements" are Map.Entry. Usually, this type of value is used to represent a particular "type" of "key" that is associated to a particular "value".
    • Method Detail

      • with

        MapValue.Immutable<K,​V> with​(K key,
                                           V value)
        Associates the provided key to the provided value in the new map. If there already exists a value for the provided key, the value is replaced.
        Parameters:
        key - The key to associate to the value
        value - The value associated with the key
        Returns:
        The new value, for chaining
      • withAll

        MapValue.Immutable<K,​V> withAll​(java.util.Map<K,​V> map)
        Associates all provided Map.Entry along with all pre-existing map entries in a new MapValue.Immutable.
        Parameters:
        map - The map of key values to set
        Returns:
        The new value, for chaining
      • without

        MapValue.Immutable<K,​V> without​(K key)
        Creates a new MapValue.Immutable without the provided key and the associated value.
        Parameters:
        key - The key to exclude the association
        Returns:
        The new value, for chaining
      • withoutAll

        MapValue.Immutable<K,​V> withoutAll​(java.lang.Iterable<K> keys)
        Creates a new MapValue.Immutable without the provided keys and their associated values.
        Parameters:
        keys - The keys to exclude
        Returns:
        The new value, for chaining
      • withoutAll

        MapValue.Immutable<K,​V> withoutAll​(java.util.function.Predicate<java.util.Map.Entry<K,​V>> predicate)
        Creates a new MapValue.Immutable such that all entries are filtered by the provided Predicate, any that return true are retained in the new value. Elements that return true from Predicate.test(Object) are kept, and those that return false are excluded.
        Parameters:
        predicate - The predicate to filter
        Returns:
        The new value, for chaining
      • asMutable

        MapValue.Mutable<K,​V> asMutable()
        Description copied from interface: Value
        Retrieves a mutable form of this value. Due to the vague nature of the value itself, some cases can already provide a Value.Mutable instance where this would simply return itself. In other cases, where the retrieved value is an Value.Immutable instance, a new mutable value is created with the same key and values.
        Specified by:
        asMutable in interface MapValue<K,​V>
        Specified by:
        asMutable in interface Value<K>
        Specified by:
        asMutable in interface Value.Immutable<K>
        Returns:
        A mutable value
      • asImmutable

        default MapValue.Immutable<K,​V> asImmutable()
        Description copied from interface: Value
        Retrieves an immutable form of this value. Due to the vague nature of the value itself, some cases can already provide a Value.Immutable instance where this would simply return itself. In other cases, where the retrieved value is a Value.Mutable instance, a new immutable value is created with the same key and values.
        Specified by:
        asImmutable in interface MapValue<K,​V>
        Specified by:
        asImmutable in interface Value<K>
        Specified by:
        asImmutable in interface Value.Immutable<K>
        Returns:
        An immutable value