Package org.spongepowered.api.data.value
Interface 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>>
-
- 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>
,java.lang.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 java.util.Collection<E>>
public static interface 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>> extends Value.Immutable<C>, CollectionValue<E,C>
AValue.Immutable
type that handles aCollection
of elements typeE
. All of the methods provided for modification return new instances of the same type. Likewise, the underlyingValueContainer
is not modified.
-
-
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 default I
asImmutable()
Retrieves an immutable form of this value.M
asMutable()
Creates a mutableValue.Mutable
for thisValue.Immutable
.default M
asMutableCopy()
Retrieves a copy in the mutable form of this value.I
transform(java.util.function.Function<C,C> function)
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.I
with(C value)
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
.I
withAll(java.lang.Iterable<E> elements)
Creates a newCollectionValue.Immutable
with the given elements along with any pre-existing values within this value.I
withElement(E element)
Creates a newCollectionValue.Immutable
with the given values along with any pre-existing values within this value.I
without(E element)
Creates a newCollectionValue.Immutable
without the givenE
element.I
withoutAll(java.lang.Iterable<E> elements)
Creates a newCollectionValue.Immutable
without the given elements of the providedIterable
.I
withoutAll(java.util.function.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
-
-
-
-
Method Detail
-
withElement
I withElement(E element)
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
I withAll(java.lang.Iterable<E> elements)
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:
Collection.addAll(Collection)
-
without
I without(E element)
Creates a newCollectionValue.Immutable
without the givenE
element.- Parameters:
element
- The element to exclude- Returns:
- The new value
-
withoutAll
I withoutAll(java.lang.Iterable<E> elements)
Creates a newCollectionValue.Immutable
without the given elements of the providedIterable
.- Parameters:
elements
- The elements to exclude- Returns:
- The new value
-
withoutAll
I withoutAll(java.util.function.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
.- Parameters:
predicate
- The predicate to apply- Returns:
- The new value
-
with
I with(C value)
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
I transform(java.util.function.Function<C,C> function)
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
.
-
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.Immutable<E>
- Returns:
- A mutable value
-
asImmutable
default I 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 java.util.Collection<E>>
- Specified by:
asImmutable
in interfaceValue<E>
- Specified by:
asImmutable
in interfaceValue.Immutable<E>
- Returns:
- An immutable value
-
-