Package org.spongepowered.api.data.value
Interface CollectionValue.Mutable<E,C extends 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> 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 Collection<E>>
public static interface CollectionValue.Mutable<E,C extends 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>, Iterable<E>
Represents a
Value.Mutable
that is backed by a Collection
of
elements.-
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.Value
Value.Factory, Value.Immutable<E>, Value.Mutable<E>
-
Method Summary
Modifier and TypeMethodDescriptionAdds the givenelement
to thisCollectionValue.Mutable
.Gets theValue.Immutable
version of thisValue.Mutable
such that all data is duplicated across to the newValue.Immutable
.default M
Retrieves a mutable form of this value.default M
Retrieves a copy in the mutable form of this value.copy()
Makes an independent copy of thisValue.Mutable
with the same initial data.Removes the givenelement
from the backedCollection
.Removes all elements from theIterable
from the backedCollection
.Iterates over all existing elements and removes any elements thatPredicate.test(Object)
returnstrue
.Sets the underlying value to the providedvalue
.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
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
add
Adds the givenelement
to thisCollectionValue.Mutable
.- Parameters:
element
- The element to add- Returns:
- This value, for chaining
-
addAll
- Parameters:
elements
- The elements to add- Returns:
- This value, for chaining
- See Also:
-
remove
Removes the givenelement
from the backedCollection
.- Parameters:
element
- The element to remove- Returns:
- This value, for chaining
-
removeAll
Removes all elements from theIterable
from the backedCollection
.- Parameters:
elements
- The elements to remove- Returns:
- This value, for chaining
-
removeAll
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
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
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
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 Collection<E>> - Specified by:
asMutableCopy
in interfaceValue<E>
- Specified by:
asMutableCopy
in interfaceValue.Mutable<E>
- Returns:
- A mutable value
-
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,
C extends Collection<E>> - Specified by:
asMutable
in interfaceValue<E>
- Specified by:
asMutable
in interfaceValue.Mutable<E>
- Returns:
- A mutable value
-
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 Collection<E>> - Specified by:
asImmutable
in interfaceValue<E>
- Specified by:
asImmutable
in interfaceValue.Mutable<E>
- Returns:
- A new
Value.Immutable
instance
-