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 ofCollectionI- The extendedCollectionValue.Immutablefor self referencingM- The mutableCollectionValue.Mutablecounterpart 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.Immutabletype that handles aCollectionof elements typeE. All of the methods provided for modification return new instances of the same type. Likewise, the underlyingValueContaineris 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 IasImmutable()Retrieves an immutable form of this value.MasMutable()Creates a mutableValue.Mutablefor thisValue.Immutable.default MasMutableCopy()Retrieves a copy in the mutable form of this value.Itransform(java.util.function.Function<C,C> function)Retrieves the underlying value for thisValue.Immutableand applies the givenFunctiononto that value, after which, the product is sent to a newValue.Immutablereplacing this one.Iwith(C value)Creates a newValue.Immutablewith the givenEtyped value, such that if the owningValueContaineris immutable, theValueContainertoo is recreated as a new instance with the newValue.Immutable.IwithAll(java.lang.Iterable<E> elements)Creates a newCollectionValue.Immutablewith the given elements along with any pre-existing values within this value.IwithElement(E element)Creates a newCollectionValue.Immutablewith the given values along with any pre-existing values within this value.Iwithout(E element)Creates a newCollectionValue.Immutablewithout the givenEelement.IwithoutAll(java.lang.Iterable<E> elements)Creates a newCollectionValue.Immutablewithout the given elements of the providedIterable.IwithoutAll(java.util.function.Predicate<E> predicate)Creates a newCollectionValue.Immutablewith elements that when the givenPredicateisPredicate.test(Object)on the element andtrueis 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.Immutablewith 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.Immutablewith 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.Immutablewithout the givenEelement.- Parameters:
element- The element to exclude- Returns:
- The new value
-
withoutAll
I withoutAll(java.lang.Iterable<E> elements)
Creates a newCollectionValue.Immutablewithout 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.Immutablewith elements that when the givenPredicateisPredicate.test(Object)on the element andtrueis 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.ImmutableCreates a newValue.Immutablewith the givenEtyped value, such that if the owningValueContaineris immutable, theValueContainertoo is recreated as a new instance with the newValue.Immutable.- Specified by:
within 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.ImmutableRetrieves the underlying value for thisValue.Immutableand applies the givenFunctiononto that value, after which, the product is sent to a newValue.Immutablereplacing this one.If the
ValueContainertoo is immutable, a new instance of theValueContainermay be created. If theValueContaineris mutable, the same instance of theValueContaineris retained.- Specified by:
transformin 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.ImmutableCreates a mutableValue.Mutablefor thisValue.Immutable.
-
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 java.util.Collection<E>>- Specified by:
asMutableCopyin interfaceValue<E>- Specified by:
asMutableCopyin interfaceValue.Immutable<E>- Returns:
- A mutable value
-
asImmutable
default I asImmutable()
Description copied from interface:ValueRetrieves an immutable form of this value. Due to the vague nature of the value itself, some cases can already provide aValue.Immutableinstance where this would simply return itself. In other cases, where the retrieved value is aValue.Mutableinstance, a new immutable value is created with the same key and values.- Specified by:
asImmutablein interfaceCollectionValue<E,C extends java.util.Collection<E>>- Specified by:
asImmutablein interfaceValue<E>- Specified by:
asImmutablein interfaceValue.Immutable<E>- Returns:
- An immutable value
-
-