Interface ListValue.Mutable<E>

Type Parameters:
E - The type of element of this list value
All Superinterfaces:
CollectionValue<E,List<E>>, CollectionValue.Mutable<E,List<E>,ListValue.Mutable<E>,ListValue.Immutable<E>>, Iterable<E>, ListValue<E>, Value<List<E>>, Value.Mutable<List<E>>
Enclosing interface:
ListValue<E>

public static interface ListValue.Mutable<E> extends ListValue<E>, CollectionValue.Mutable<E,List<E>,ListValue.Mutable<E>,ListValue.Immutable<E>>
A type of CollectionValue.Mutable that is backed by a List. All mutator methods provided are similar to those existing in List with the difference of returning itself, for fluency.
  • Method Details

    • add

      ListValue.Mutable<E> add(int index, E value)
      Adds the specified element at the specified position in the list. As well, the element at the provided index is shifted to the right, increasing its and the elements thereafter their indices by one.
      Parameters:
      index - The index to add the provided element at
      value - The element to add
      Returns:
      This value, for chaining
    • add

      ListValue.Mutable<E> add(int index, Iterable<E> values)
      Adds the specified elements in the order that they are iterated to the list at the specified index. The element at the provided index and elements thereafter are shifted to the right, increasing their indices by one.
      Parameters:
      index - The index to add the elements at
      values - The elements to add
      Returns:
      This value, for chaining
    • remove

      ListValue.Mutable<E> remove(int index)
      Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left, subtracts one from their indices.
      Parameters:
      index - The index of the element to remove
      Returns:
      This value, for chaining
    • set

      ListValue.Mutable<E> set(int index, E element)
      Replaces the element at the specified index in this list with the specified element.
      Parameters:
      index - The index to replace the element with
      element - The element to set
      Returns:
      This value, for chaining
    • asMutable

      default ListValue.Mutable<E> 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 CollectionValue<E,List<E>>
      Specified by:
      asMutable in interface CollectionValue.Mutable<E,List<E>,ListValue.Mutable<E>,ListValue.Immutable<E>>
      Specified by:
      asMutable in interface ListValue<E>
      Specified by:
      asMutable in interface Value<E>
      Specified by:
      asMutable in interface Value.Mutable<E>
      Returns:
      A mutable value
    • asImmutable

      ListValue.Immutable<E> 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 CollectionValue<E,List<E>>
      Specified by:
      asImmutable in interface CollectionValue.Mutable<E,List<E>,ListValue.Mutable<E>,ListValue.Immutable<E>>
      Specified by:
      asImmutable in interface ListValue<E>
      Specified by:
      asImmutable in interface Value<E>
      Specified by:
      asImmutable in interface Value.Mutable<E>
      Returns:
      An immutable value