Package org.spongepowered.api.data.value
Interface CollectionValue.Immutable<E,C extends Collection<E>,I extends CollectionValue.Immutable<E,C,I,M>,M extends CollectionValue.Mutable<E,C,M,I>>
- Type Parameters:
E
- The type of elementC
- The type ofCollection
I
- The extendedCollectionValue.Immutable
for self referencingM
- The mutableCollectionValue.Mutable
counterpart forasMutable()
- All Superinterfaces:
CollectionValue<E,
,C> Iterable<E>
,Value<C>
,Value.Immutable<C>
- All Known Subinterfaces:
ListValue.Immutable<E>
,SetValue.Immutable<E>
,WeightedCollectionValue.Immutable<E>
- Enclosing interface:
CollectionValue<E,
C extends Collection<E>>
public static interface CollectionValue.Immutable<E,C extends Collection<E>,I extends CollectionValue.Immutable<E,C,I,M>,M extends CollectionValue.Mutable<E,C,M,I>>
extends Value.Immutable<C>, CollectionValue<E,C>
A
Value.Immutable
type that handles a Collection
of elements
type E
. All of the methods provided for modification return new
instances of the same type. Likewise, the underlying ValueContainer
is not modified.-
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 TypeMethodDescriptiondefault I
Retrieves an immutable form of this value.Creates a mutableValue.Mutable
for thisValue.Immutable
.default M
Retrieves a copy in the mutable form of this value.Retrieves the underlying value for thisValue.Immutable
and applies the givenFunction
onto that value, after which, the product is sent to a newValue.Immutable
replacing this one.Creates a newValue.Immutable
with the givenE
typed value, such that if the owningValueContainer
is immutable, theValueContainer
too is recreated as a new instance with the newValue.Immutable
.Creates a newCollectionValue.Immutable
with the given elements along with any pre-existing values within this value.withElement
(E element) Creates a newCollectionValue.Immutable
with the given values along with any pre-existing values within this value.Creates a newCollectionValue.Immutable
without the givenE
element.withoutAll
(Iterable<E> elements) Creates a newCollectionValue.Immutable
without the given elements of the providedIterable
.withoutAll
(Predicate<E> predicate) Creates a newCollectionValue.Immutable
with elements that when the givenPredicate
isPredicate.test(Object)
on the element andtrue
is returned, the element will remain in the newCollectionValue.Immutable
.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
-
withElement
Creates a newCollectionValue.Immutable
with the given values along with any pre-existing values within this value.- Parameters:
element
- The element to add- Returns:
- The new value
-
withAll
Creates a newCollectionValue.Immutable
with the given elements along with any pre-existing values within this value.- Parameters:
elements
- The elements to add- Returns:
- The new value
- See Also:
-
without
Creates a newCollectionValue.Immutable
without the givenE
element.- Parameters:
element
- The element to exclude- Returns:
- The new value
-
withoutAll
Creates a newCollectionValue.Immutable
without the given elements of the providedIterable
.- Parameters:
elements
- The elements to exclude- Returns:
- The new value
-
withoutAll
Creates a newCollectionValue.Immutable
with elements that when the givenPredicate
isPredicate.test(Object)
on the element andtrue
is returned, the element will remain in the newCollectionValue.Immutable
.- Parameters:
predicate
- The predicate to apply- Returns:
- The new value
-
with
Description copied from interface:Value.Immutable
Creates a newValue.Immutable
with the givenE
typed value, such that if the owningValueContainer
is immutable, theValueContainer
too is recreated as a new instance with the newValue.Immutable
.- Specified by:
with
in interfaceValue.Immutable<E>
- Parameters:
value
- The value to replace- Returns:
- The owning
ValueContainer
, a new instance if it too is immutable
-
transform
Description copied from interface:Value.Immutable
Retrieves the underlying value for thisValue.Immutable
and applies the givenFunction
onto that value, after which, the product is sent to a newValue.Immutable
replacing this one.If the
ValueContainer
too is immutable, a new instance of theValueContainer
may be created. If theValueContainer
is mutable, the same instance of theValueContainer
is retained.- Specified by:
transform
in interfaceValue.Immutable<E>
- Parameters:
function
- The function to apply onto the existing value- Returns:
- The owning
ValueContainer
, a new instance if it too is immutable
-
asMutable
M asMutable()Description copied from interface:Value.Immutable
Creates a mutableValue.Mutable
for thisValue.Immutable
.- Specified by:
asMutable
in interfaceCollectionValue<E,
C extends Collection<E>> - Specified by:
asMutable
in interfaceValue<E>
- Specified by:
asMutable
in interfaceValue.Immutable<E>
- Returns:
- A mutable value
-
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.Immutable<E>
- Returns:
- A mutable value
-
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,
C extends Collection<E>> - Specified by:
asImmutable
in interfaceValue<E>
- Specified by:
asImmutable
in interfaceValue.Immutable<E>
- Returns:
- An immutable value
-