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 aDataHolderthat 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 ImergeWith(I that)Attempts to merge theValue.Immutables from thisDataHolder.Immutableand the givenDataHolder.Immutableto produce a new instance of the merged result.ImergeWith(I that, MergeFunction function)Attempts to merge theValue.Immutables from thisDataHolder.Immutableand the givenDataHolder.Immutableto produce a new instance of the merged result.default <E> Optional<I>transform(Supplier<? extends Key<? extends Value<E>>> key, Function<E,E> function)Applies a transformation on the providedValuesuch that the return value ofFunction.apply(Object)will become the end resulting value set into the newly createdDataHolder.Immutable.<E> Optional<I>transform(Key<? extends Value<E>> key, Function<E,E> function)Applies a transformation on the providedValuesuch that the return value ofFunction.apply(Object)will become the end resulting value set into the newly createdDataHolder.Immutable.default <E> Optional<I>with(Supplier<? extends Key<? extends Value<E>>> key, E value)Creates a newDataHolder.Immutablewith the provided value byKey.<E> Optional<I>with(Key<? extends Value<E>> key, E value)Creates a newDataHolder.Immutablewith the provided value byKey.Optional<I>with(Value<?> value)Offers the givenvalueas defined by the providedKeysuch that if theKeyis supported, a newDataHolder.Immutableis created.default Optional<I>without(Supplier<? extends Key<?>> key)Creates a newDataHolder.Immutablewithout the providedKey.Optional<I>without(Key<?> key)Creates a newDataHolder.Immutablewithout the providedKey.default Optional<I>without(Value<?> value)Creates a newDataHolder.Immutablewithout the key of the providedValue.
-
-
-
Method Detail
-
transform
<E> Optional<I> transform(Key<? extends Value<E>> key, Function<E,E> function)
Applies a transformation on the providedValuesuch 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> Optional<I> transform(Supplier<? extends Key<? extends Value<E>>> key, Function<E,E> function)
Applies a transformation on the providedValuesuch 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> Optional<I> with(Key<? extends Value<E>> key, E value)
Creates a newDataHolder.Immutablewith 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> Optional<I> with(Supplier<? extends Key<? extends Value<E>>> key, E value)
Creates a newDataHolder.Immutablewith 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
Optional<I> with(Value<?> value)
Offers the givenvalueas defined by the providedKeysuch that if theKeyis supported, a newDataHolder.Immutableis created.- Parameters:
value- The value to set- Returns:
- The new immutable value store
-
without
default Optional<I> without(Value<?> value)
Creates a newDataHolder.Immutablewithout 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
Optional<I> without(Key<?> key)
Creates a newDataHolder.Immutablewithout 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 Optional<I> without(Supplier<? extends Key<?>> key)
Creates a newDataHolder.Immutablewithout 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.Immutables from thisDataHolder.Immutableand the givenDataHolder.Immutableto 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.Immutables from thisDataHolder.Immutableand the givenDataHolder.Immutableto produce a new instance of the merged result. Any overlappingValueContainers 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
-
-