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 a DataHolder that is immutable and can be transformed into other immutable data holders.
  • Method Details

    • transform

      <E> Optional<I> transform(Key<? extends Value<E>> key, Function<E,E> function)
      Applies a transformation on the provided Value such that the return value of Function.apply(Object) will become the end resulting value set into the newly created DataHolder.Immutable.
      Type Parameters:
      E - The type of value
      Parameters:
      key - The key linked to
      function - 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 provided Value such that the return value of Function.apply(Object) will become the end resulting value set into the newly created DataHolder.Immutable.
      Type Parameters:
      E - The type of value
      Parameters:
      key - The key linked to
      function - 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 new DataHolder.Immutable with the provided value by Key. 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 set
      value - 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 new DataHolder.Immutable with the provided value by Key. 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 set
      value - The value to set
      Returns:
      The new immutable value store
    • with

      Optional<I> with(Value<?> value)
      Offers the given value as defined by the provided Key such that if the Key is supported, a new DataHolder.Immutable is created.
      Parameters:
      value - The value to set
      Returns:
      The new immutable value store
    • without

      default Optional<I> without(Value<?> value)
      Creates a new DataHolder.Immutable without the key of the provided Value. 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 new DataHolder.Immutable without the provided Key. 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 new DataHolder.Immutable without the provided Key. 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 the Value.Immutables from this DataHolder.Immutable and the given DataHolder.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 the Value.Immutables from this DataHolder.Immutable and the given DataHolder.Immutable to produce a new instance of the merged result. Any overlapping ValueContainers are merged through the MergeFunction.
      Parameters:
      that - The other immutable value store to gather values from
      function - The function to resolve merge conflicts
      Returns:
      The new immutable value store instance