Class DataComponentEditor

java.lang.Object
fr.fidorial.item.data.DataComponentEditor
All Implemented Interfaces:
DataComponentHolder

public final class DataComponentEditor extends Object implements DataComponentHolder
The writing half of the component model: a mutable, chainable editor over one holder's components.
Since:
0.1.0
  • Method Details

    • empty

      public static DataComponentEditor empty()
      Returns:
      an editor patching nothing
      Since:
      0.1.0
    • of

      public static DataComponentEditor of(DataComponentMap components)
      Parameters:
      components - the patch to start from
      Returns:
      an editor over that patch
      Since:
      0.1.0
    • components

      public DataComponentMap components()
      Specified by:
      components in interface DataComponentHolder
      Returns:
      the patch this holder carries
    • copy

      public DataComponentEditor copy()
      Returns:
      an independent editor holding the same components
      Since:
      0.1.0
    • isEmpty

      public boolean isEmpty()
      Returns:
      true when this editor patches nothing
      Since:
      0.1.0
    • set

      public <T> DataComponentEditor set(DataComponentType<T> type, T value)
      Type Parameters:
      T - the component's value type
      Parameters:
      type - the component to set
      value - the value
      Returns:
      this editor
      Since:
      0.1.0
    • setOrReset

      public <T> DataComponentEditor setOrReset(DataComponentType<T> type, @Nullable T value)
      Type Parameters:
      T - the component's value type
      Parameters:
      type - the component to set
      value - the value, or null to stop patching the component
      Returns:
      this editor
      Since:
      0.1.0
    • remove

      public DataComponentEditor remove(DataComponentType<?> type)
      Takes the item's own default away, so the component ends up absent from the item rather than back at its default.
      Parameters:
      type - the component to remove
      Returns:
      this editor
      Since:
      0.1.0
    • reset

      public DataComponentEditor reset(DataComponentType<?> type)
      Drops this editor's opinion on a component, letting the item's default show through again.
      Parameters:
      type - the component to stop patching
      Returns:
      this editor
      Since:
      0.1.0
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object