Package org.spongepowered.api.data
Interface DataHolder.Immutable<I extends DataHolder.Immutable<I>>
-
- All Superinterfaces:
DataHolder
,ValueContainer
- All Known Subinterfaces:
BlockSnapshot
,BlockState
,BlockType
,DirectionRelativeDataHolder.Immutable<I>
,EntitySnapshot
,FluidStackSnapshot
,FluidState
,FluidType
,ItemStackSnapshot
,ItemType
,LocatableBlock
,LocatableSnapshot<T>
,SerializableDataHolder.Immutable<I>
,State<S>
- Enclosing interface:
- DataHolder
public static interface DataHolder.Immutable<I extends DataHolder.Immutable<I>> extends DataHolder
Represents aDataHolder
that is immutable and can be transformed into other immutable data holders.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.Mutable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default I
mergeWith(I that)
Attempts to merge theValue.Immutable
s from thisDataHolder.Immutable
and the givenDataHolder.Immutable
to produce a new instance of the merged result.I
mergeWith(I that, MergeFunction function)
Attempts to merge theValue.Immutable
s from thisDataHolder.Immutable
and the givenDataHolder.Immutable
to produce a new instance of the merged result.default <E> java.util.Optional<I>
transform(java.util.function.Supplier<? extends Key<? extends Value<E>>> key, java.util.function.Function<E,E> function)
Applies a transformation on the providedValue
such that the return value ofFunction.apply(Object)
will become the end resulting value set into the newly createdDataHolder.Immutable
.<E> java.util.Optional<I>
transform(Key<? extends Value<E>> key, java.util.function.Function<E,E> function)
Applies a transformation on the providedValue
such that the return value ofFunction.apply(Object)
will become the end resulting value set into the newly createdDataHolder.Immutable
.default <E> java.util.Optional<I>
with(java.util.function.Supplier<? extends Key<? extends Value<E>>> key, E value)
Creates a newDataHolder.Immutable
with the provided value byKey
.<E> java.util.Optional<I>
with(Key<? extends Value<E>> key, E value)
Creates a newDataHolder.Immutable
with the provided value byKey
.java.util.Optional<I>
with(Value<?> value)
Offers the givenvalue
as defined by the providedKey
such that if theKey
is supported, a newDataHolder.Immutable
is created.default java.util.Optional<I>
without(java.util.function.Supplier<? extends Key<?>> key)
Creates a newDataHolder.Immutable
without the providedKey
.java.util.Optional<I>
without(Key<?> key)
Creates a newDataHolder.Immutable
without the providedKey
.default java.util.Optional<I>
without(Value<?> value)
Creates a newDataHolder.Immutable
without the key of the providedValue
.
-
-
-
Method Detail
-
transform
<E> java.util.Optional<I> transform(Key<? extends Value<E>> key, java.util.function.Function<E,E> function)
Applies a transformation on the providedValue
such that the return value ofFunction.apply(Object)
will become the end resulting value set into the newly createdDataHolder.Immutable
.- Type Parameters:
E
- The type of value- Parameters:
key
- The key linked tofunction
- The function to manipulate the value- Returns:
- The newly created immutable value store
-
transform
default <E> java.util.Optional<I> transform(java.util.function.Supplier<? extends Key<? extends Value<E>>> key, java.util.function.Function<E,E> function)
Applies a transformation on the providedValue
such that the return value ofFunction.apply(Object)
will become the end resulting value set into the newly createdDataHolder.Immutable
.- Type Parameters:
E
- The type of value- Parameters:
key
- The key linked tofunction
- The function to manipulate the value- Returns:
- The newly created immutable value store
-
with
<E> java.util.Optional<I> with(Key<? extends Value<E>> key, E value)
Creates a newDataHolder.Immutable
with the provided value byKey
. If the key is supported by this value store, the returned value store will be present.- Type Parameters:
E
- The type of value- Parameters:
key
- The key to the value to setvalue
- The value to set- Returns:
- The new immutable value store
-
with
default <E> java.util.Optional<I> with(java.util.function.Supplier<? extends Key<? extends Value<E>>> key, E value)
Creates a newDataHolder.Immutable
with the provided value byKey
. If the key is supported by this value store, the returned value store will be present.- Type Parameters:
E
- The type of value- Parameters:
key
- The key to the value to setvalue
- The value to set- Returns:
- The new immutable value store
-
with
java.util.Optional<I> with(Value<?> value)
Offers the givenvalue
as defined by the providedKey
such that if theKey
is supported, a newDataHolder.Immutable
is created.- Parameters:
value
- The value to set- Returns:
- The new immutable value store
-
without
default java.util.Optional<I> without(Value<?> value)
Creates a newDataHolder.Immutable
without the key of the providedValue
. If the key is supported by this value store, the returned value store will be present.- Parameters:
value
- The value- Returns:
- The new immutable value store
-
without
java.util.Optional<I> without(Key<?> key)
Creates a newDataHolder.Immutable
without the providedKey
. If the key is supported by this value store, the returned value store will be present.- Parameters:
key
- The key to remove- Returns:
- The new immutable value store
-
without
default java.util.Optional<I> without(java.util.function.Supplier<? extends Key<?>> key)
Creates a newDataHolder.Immutable
without the providedKey
. If the key is supported by this value store, the returned value store will be present.- Parameters:
key
- The key to remove- Returns:
- The new immutable value store
-
mergeWith
default I mergeWith(I that)
Attempts to merge theValue.Immutable
s from thisDataHolder.Immutable
and the givenDataHolder.Immutable
to produce a new instance of the merged result.- Parameters:
that
- The other immutable value store to gather values from- Returns:
- The new immutable value store instance
-
mergeWith
I mergeWith(I that, MergeFunction function)
Attempts to merge theValue.Immutable
s from thisDataHolder.Immutable
and the givenDataHolder.Immutable
to produce a new instance of the merged result. Any overlappingValueContainer
s are merged through theMergeFunction
.- Parameters:
that
- The other immutable value store to gather values fromfunction
- The function to resolve merge conflicts- Returns:
- The new immutable value store instance
-
-