Package org.spongepowered.api.data.value
Interface 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>>
-
- Type Parameters:
E
- The type of elementC
- The type of collection, for chainingM
- The type of CollectionValue.MutableI
- The type ofCollectionValue.Immutable
- All Superinterfaces:
CollectionValue<E,C>
,java.lang.Iterable<E>
,Value<C>
,Value.Mutable<C>
- All Known Subinterfaces:
ListValue.Mutable<E>
,SetValue.Mutable<E>
,WeightedCollectionValue.Mutable<E>
- Enclosing interface:
- CollectionValue<E,C extends java.util.Collection<E>>
public static interface 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>> extends Value.Mutable<C>, CollectionValue<E,C>, java.lang.Iterable<E>
Represents aValue.Mutable
that is backed by aCollection
of elements.
-
-
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.Value
Value.Factory, Value.Immutable<E>, Value.Mutable<E>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description M
add(E element)
Adds the givenelement
to thisCollectionValue.Mutable
.M
addAll(java.lang.Iterable<E> elements)
Adds all the givenIterable
elements
to the underlyingCollection
.I
asImmutable()
Gets theValue.Immutable
version of thisValue.Mutable
such that all data is duplicated across to the newValue.Immutable
.default M
asMutable()
Retrieves a mutable form of this value.default M
asMutableCopy()
Retrieves a copy in the mutable form of this value.M
copy()
Makes an independent copy of thisValue.Mutable
with the same initial data.M
remove(E element)
Removes the givenelement
from the backedCollection
.M
removeAll(java.lang.Iterable<E> elements)
Removes all elements from theIterable
from the backedCollection
.M
removeAll(java.util.function.Predicate<E> predicate)
Iterates over all existing elements and removes any elements thatPredicate.test(Object)
returnstrue
.M
set(C value)
Sets the underlying value to the providedvalue
.M
transform(java.util.function.Function<C,C> function)
Attempts to transform the underlying value based on the providedFunction
such that the result ofFunction.apply(Object)
will replace the underlying value.-
Methods inherited from interface org.spongepowered.api.data.value.CollectionValue
all, contains, containsAll, isEmpty, size
-
-
-
-
Method Detail
-
add
M add(E element)
Adds the givenelement
to thisCollectionValue.Mutable
.- Parameters:
element
- The element to add- Returns:
- This value, for chaining
-
addAll
M addAll(java.lang.Iterable<E> elements)
Adds all the givenIterable
elements
to the underlyingCollection
.- Parameters:
elements
- The elements to add- Returns:
- This value, for chaining
- See Also:
Collection.addAll(Collection)
-
remove
M remove(E element)
Removes the givenelement
from the backedCollection
.- Parameters:
element
- The element to remove- Returns:
- This value, for chaining
-
removeAll
M removeAll(java.lang.Iterable<E> elements)
Removes all elements from theIterable
from the backedCollection
.- Parameters:
elements
- The elements to remove- Returns:
- This value, for chaining
-
removeAll
M removeAll(java.util.function.Predicate<E> predicate)
Iterates over all existing elements and removes any elements thatPredicate.test(Object)
returnstrue
.- Parameters:
predicate
- The predicate to remove elements- Returns:
- This value, for chaining
-
set
M set(C value)
Description copied from interface:Value.Mutable
Sets the underlying value to the providedvalue
.- Specified by:
set
in interfaceValue.Mutable<E>
- Parameters:
value
- The value to set- Returns:
- The owning
ValueContainer
-
transform
M transform(java.util.function.Function<C,C> function)
Description copied from interface:Value.Mutable
Attempts to transform the underlying value based on the providedFunction
such that the result ofFunction.apply(Object)
will replace the underlying value.- Specified by:
transform
in interfaceValue.Mutable<E>
- Parameters:
function
- The function to apply on the existing value- Returns:
- The owning
ValueContainer
-
copy
M copy()
Description copied from interface:Value.Mutable
Makes an independent copy of thisValue.Mutable
with the same initial data. Both this value and the new value will refer to the same object initially.- Specified by:
copy
in interfaceValue.Mutable<E>
- Returns:
- A new copy of this
Value.Mutable
-
asMutableCopy
default M asMutableCopy()
Description copied from interface:Value
Retrieves a copy in the mutable form of this value. The new is created with the same key and values.- Specified by:
asMutableCopy
in interfaceCollectionValue<E,C extends java.util.Collection<E>>
- Specified by:
asMutableCopy
in interfaceValue<E>
- Specified by:
asMutableCopy
in interfaceValue.Mutable<E>
- Returns:
- A mutable value
-
asMutable
default M 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.
-
asImmutable
I asImmutable()
Description copied from interface:Value.Mutable
Gets theValue.Immutable
version of thisValue.Mutable
such that all data is duplicated across to the newValue.Immutable
. Note that once created, theValue.Immutable
is not going to change.- Specified by:
asImmutable
in interfaceCollectionValue<E,C extends java.util.Collection<E>>
- Specified by:
asImmutable
in interfaceValue<E>
- Specified by:
asImmutable
in interfaceValue.Mutable<E>
- Returns:
- A new
Value.Immutable
instance
-
-