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 givenelementto thisCollectionValue.Mutable.Gets theValue.Immutableversion of thisValue.Mutablesuch that all data is duplicated across to the newValue.Immutable.default MRetrieves a mutable form of this value.default MRetrieves a copy in the mutable form of this value.copy()Makes an independent copy of thisValue.Mutablewith the same initial data.Removes the givenelementfrom the backedCollection.Removes all elements from theIterablefrom 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 providedFunctionsuch 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, sizeMethods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
add
Adds the givenelementto 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 givenelementfrom the backedCollection.- Parameters:
element- The element to remove- Returns:
- This value, for chaining
-
removeAll
Removes all elements from theIterablefrom 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.MutableSets the underlying value to the providedvalue.- Specified by:
setin interfaceValue.Mutable<E>- Parameters:
value- The value to set- Returns:
- The owning
ValueContainer
-
transform
Description copied from interface:Value.MutableAttempts to transform the underlying value based on the providedFunctionsuch that the result ofFunction.apply(Object)will replace the underlying value.- Specified by:
transformin 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.MutableMakes an independent copy of thisValue.Mutablewith the same initial data. Both this value and the new value will refer to the same object initially.- Specified by:
copyin interfaceValue.Mutable<E>- Returns:
- A new copy of this
Value.Mutable
-
asMutableCopy
Description copied from interface:ValueRetrieves a copy in the mutable form of this value. The new is created with the same key and values.- Specified by:
asMutableCopyin interfaceCollectionValue<E,C extends Collection<E>> - Specified by:
asMutableCopyin interfaceValue<E>- Specified by:
asMutableCopyin interfaceValue.Mutable<E>- Returns:
- A mutable value
-
asMutable
Description copied from interface:ValueRetrieves a mutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Mutableinstance where this would simply return itself. In other cases, where the retrieved value is anValue.Immutableinstance, a new mutable value is created with the same key and values.- Specified by:
asMutablein interfaceCollectionValue<E,C extends Collection<E>> - Specified by:
asMutablein interfaceValue<E>- Specified by:
asMutablein interfaceValue.Mutable<E>- Returns:
- A mutable value
-
asImmutable
I asImmutable()Description copied from interface:Value.MutableGets theValue.Immutableversion of thisValue.Mutablesuch that all data is duplicated across to the newValue.Immutable. Note that once created, theValue.Immutableis not going to change.- Specified by:
asImmutablein interfaceCollectionValue<E,C extends Collection<E>> - Specified by:
asImmutablein interfaceValue<E>- Specified by:
asImmutablein interfaceValue.Mutable<E>- Returns:
- A new
Value.Immutableinstance
-