Package org.spongepowered.api.data.value
Interface ListValue.Immutable<E>
-
- Type Parameters:
E
- The type of element of this list value
- All Superinterfaces:
CollectionValue<E,List<E>>
,CollectionValue.Immutable<E,List<E>,ListValue.Immutable<E>,ListValue.Mutable<E>>
,Iterable<E>
,ListValue<E>
,Value<List<E>>
,Value.Immutable<List<E>>
public static interface ListValue.Immutable<E> extends ListValue<E>, CollectionValue.Immutable<E,List<E>,ListValue.Immutable<E>,ListValue.Mutable<E>>
A type ofCollectionValue.Immutable
that is backed by aList
. All "with" and "Without" methods are returning new instances as every instance is immutable.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.value.CollectionValue
CollectionValue.Immutable<E,C extends Collection<E>,I extends CollectionValue.Immutable<E,C,I,M>,M extends CollectionValue.Mutable<E,C,M,I>>, CollectionValue.Mutable<E,C extends 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 default ListValue.Immutable<E>
asImmutable()
Retrieves an immutable form of this value.ListValue.Mutable<E>
asMutable()
Retrieves a mutable form of this value.ListValue.Immutable<E>
set(int index, E element)
Creates a newListValue.Immutable
with the desired element at the desired index.ListValue.Immutable<E>
with(int index, E value)
Creates a newListValue.Immutable
with the specified element at the specified position in the list.ListValue.Immutable<E>
with(int index, Iterable<E> values)
Creates a newListValue.Immutable
with the specified elements in the order that they are iterated to the list at the specified index.ListValue.Immutable<E>
without(int index)
Creates a newListValue.Immutable
without the element at the specified index.-
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.Immutable
asMutableCopy, transform, with, withAll, withElement, without, withoutAll, withoutAll
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
with
ListValue.Immutable<E> with(int index, E value)
Creates a newListValue.Immutable
with 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:
- The new value, for chaining
-
with
ListValue.Immutable<E> with(int index, Iterable<E> values)
Creates a newListValue.Immutable
with 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:
- The new value, for chaining
-
without
ListValue.Immutable<E> without(int index)
Creates a newListValue.Immutable
without the element at the specified index. Shifts any subsequent elements to the left, subtracts one from their indices.- Parameters:
index
- The index of the element to exclude- Returns:
- The new value, for chaining
-
set
ListValue.Immutable<E> set(int index, E element)
Creates a newListValue.Immutable
with the desired element at the desired index.- Parameters:
index
- The index to replace the elementelement
- The element to include at the index- Returns:
- The new value, for chaining
-
asMutable
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,List<E>>
- Specified by:
asMutable
in interfaceCollectionValue.Immutable<E,List<E>,ListValue.Immutable<E>,ListValue.Mutable<E>>
- Specified by:
asMutable
in interfaceListValue<E>
- Specified by:
asMutable
in interfaceValue<E>
- Specified by:
asMutable
in interfaceValue.Immutable<E>
- Returns:
- A mutable value
-
asImmutable
default 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,List<E>>
- Specified by:
asImmutable
in interfaceCollectionValue.Immutable<E,List<E>,ListValue.Immutable<E>,ListValue.Mutable<E>>
- Specified by:
asImmutable
in interfaceListValue<E>
- Specified by:
asImmutable
in interfaceValue<E>
- Specified by:
asImmutable
in interfaceValue.Immutable<E>
- Returns:
- An immutable value
-
-