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 aValue.Mutablethat is backed by aCollectionof 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Madd(E element)Adds the givenelementto thisCollectionValue.Mutable.MaddAll(Iterable<E> elements)IasImmutable()Gets theValue.Immutableversion of thisValue.Mutablesuch that all data is duplicated across to the newValue.Immutable.default MasMutable()Retrieves a mutable form of this value.default MasMutableCopy()Retrieves a copy in the mutable form of this value.Mcopy()Makes an independent copy of thisValue.Mutablewith the same initial data.Mremove(E element)Removes the givenelementfrom the backedCollection.MremoveAll(Iterable<E> elements)Removes all elements from theIterablefrom the backedCollection.MremoveAll(Predicate<E> predicate)Iterates over all existing elements and removes any elements thatPredicate.test(Object)returnstrue.Mset(C value)Sets the underlying value to the providedvalue.Mtransform(Function<C,C> function)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, size
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Method Detail
-
add
M add(E element)
Adds the givenelementto thisCollectionValue.Mutable.- Parameters:
element- The element to add- Returns:
- This value, for chaining
-
addAll
M addAll(Iterable<E> elements)
- Parameters:
elements- The elements to add- Returns:
- This value, for chaining
- See Also:
Collection.addAll(Collection)
-
remove
M remove(E element)
Removes the givenelementfrom the backedCollection.- Parameters:
element- The element to remove- Returns:
- This value, for chaining
-
removeAll
M removeAll(Iterable<E> elements)
Removes all elements from theIterablefrom the backedCollection.- Parameters:
elements- The elements to remove- Returns:
- This value, for chaining
-
removeAll
M removeAll(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.MutableSets the underlying value to the providedvalue.- Specified by:
setin interfaceValue.Mutable<E>- Parameters:
value- The value to set- Returns:
- The owning
ValueContainer
-
transform
M transform(Function<C,C> function)
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
default M 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
default M 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
-
-