Package org.spongepowered.api.data.value
Interface ListValue.Mutable<E>
-
- Type Parameters:
E
- The type of element of this list value
- All Superinterfaces:
CollectionValue<E,java.util.List<E>>
,CollectionValue.Mutable<E,java.util.List<E>,ListValue.Mutable<E>,ListValue.Immutable<E>>
,java.lang.Iterable<E>
,ListValue<E>
,Value<java.util.List<E>>
,Value.Mutable<java.util.List<E>>
public static interface ListValue.Mutable<E> extends ListValue<E>, CollectionValue.Mutable<E,java.util.List<E>,ListValue.Mutable<E>,ListValue.Immutable<E>>
A type ofCollectionValue.Mutable
that is backed by aList
. All mutator methods provided are similar to those existing inList
with the difference of returning itself, for fluency.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.value.CollectionValue
CollectionValue.Immutable<E,C extends java.util.Collection<E>,I extends CollectionValue.Immutable<E,C,I,M>,M extends CollectionValue.Mutable<E,C,M,I>>, CollectionValue.Mutable<E,C extends java.util.Collection<E>,M extends CollectionValue.Mutable<E,C,M,I>,I extends CollectionValue.Immutable<E,C,I,M>>
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.value.ListValue
ListValue.Immutable<E>, ListValue.Mutable<E>
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.value.Value
Value.Factory, Value.Immutable<E>, Value.Mutable<E>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ListValue.Mutable<E>
add(int index, E value)
Adds the specified element at the specified position in the list.ListValue.Mutable<E>
add(int index, java.lang.Iterable<E> values)
Adds the specified elements in the order that they are iterated to the list at the specified index.ListValue.Immutable<E>
asImmutable()
Retrieves an immutable form of this value.default ListValue.Mutable<E>
asMutable()
Retrieves a mutable form of this value.ListValue.Mutable<E>
remove(int index)
Removes the element at the specified position in this list (optional operation).ListValue.Mutable<E>
set(int index, E element)
Replaces the element at the specified index in this list with the specified element.-
Methods inherited from interface org.spongepowered.api.data.value.CollectionValue
all, asMutableCopy, contains, containsAll, isEmpty, size
-
Methods inherited from interface org.spongepowered.api.data.value.CollectionValue.Mutable
add, addAll, asMutableCopy, copy, remove, removeAll, removeAll, set, transform
-
-
-
-
Method Detail
-
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 atvalue
- The element to add- Returns:
- This value, for chaining
-
add
ListValue.Mutable<E> add(int index, java.lang.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 atvalues
- 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 withelement
- 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 aValue.Mutable
instance where this would simply return itself. In other cases, where the retrieved value is anValue.Immutable
instance, a new mutable value is created with the same key and values.- Specified by:
asMutable
in interfaceCollectionValue<E,java.util.List<E>>
- Specified by:
asMutable
in interfaceCollectionValue.Mutable<E,java.util.List<E>,ListValue.Mutable<E>,ListValue.Immutable<E>>
- Specified by:
asMutable
in interfaceListValue<E>
- Specified by:
asMutable
in interfaceValue<E>
- Specified by:
asMutable
in interfaceValue.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 aValue.Immutable
instance where this would simply return itself. In other cases, where the retrieved value is aValue.Mutable
instance, a new immutable value is created with the same key and values.- Specified by:
asImmutable
in interfaceCollectionValue<E,java.util.List<E>>
- Specified by:
asImmutable
in interfaceCollectionValue.Mutable<E,java.util.List<E>,ListValue.Mutable<E>,ListValue.Immutable<E>>
- Specified by:
asImmutable
in interfaceListValue<E>
- Specified by:
asImmutable
in interfaceValue<E>
- Specified by:
asImmutable
in interfaceValue.Mutable<E>
- Returns:
- An immutable value
-
-