Class ActionItem

java.lang.Object
io.github.projectunified.craftux.common.ActionItem

public final class ActionItem extends Object
The action item
  • Constructor Details

    • ActionItem

      public ActionItem()
      Create an empty ActionItem
    • ActionItem

      public ActionItem(@NotNull @NotNull ActionItem actionItem, boolean applyOnlyNonnull)
      Create a copy of ActionItem
      Parameters:
      actionItem - the action item to copy
      applyOnlyNonnull - if true, only non-null fields will be copied
    • ActionItem

      public ActionItem(@NotNull @NotNull ActionItem actionItem)
      Create a copy of ActionItem
      Parameters:
      actionItem - the action item to copy
  • Method Details

    • getItem

      @Nullable public @Nullable Object getItem()
      Get the item
      Returns:
      the item
    • setItem

      public void setItem(@Nullable @Nullable Object item)
      Set the item
      Parameters:
      item - the item
    • extendItem

      public void extendItem(UnaryOperator<Object> operator)
      Extend the item
      Parameters:
      operator - the operator to extend the item
    • extendItem

      public <T> void extendItem(Class<T> itemClass, UnaryOperator<T> operator)
      Extend the item if it is of the given class
      Type Parameters:
      T - the item type
      Parameters:
      itemClass - the class to check
      operator - the operator to extend the item
    • getItem

      @Nullable public <T> T getItem(Class<T> itemClass)
      Get the item as the given class, or null if it is not of that class
      Type Parameters:
      T - the item type
      Parameters:
      itemClass - the class to check
      Returns:
      the item or null
    • getItemUnchecked

      @Nullable public <T> T getItemUnchecked()
      Get the item unchecked
      Type Parameters:
      T - the item type
      Returns:
      the item
    • getAction

      @Nullable public @Nullable Consumer<Object> getAction()
      Get the action
      Returns:
      the action
    • setAction

      public void setAction(@Nullable @Nullable Consumer<Object> action)
      Set the action
      Parameters:
      action - the action
    • extendAction

      public void extendAction(BiConsumer<Object,Consumer<Object>> operator)
      Extend the action
      Parameters:
      operator - the operator with the event and the old action
    • setAction

      public <E> void setAction(Class<E> eventClass, Consumer<E> action)
      Set the action
      Type Parameters:
      E - the event type
      Parameters:
      eventClass - the event class
      action - the action
    • extendAction

      public <E> void extendAction(Class<E> eventClass, BiConsumer<E,Consumer<Object>> operator)
      Extend the action
      Type Parameters:
      E - the event type
      Parameters:
      eventClass - the event class
      operator - the operator with the event and the old action
    • callAction

      public void callAction(Object event)
      Call the action
      Parameters:
      event - the event
    • apply

      public void apply(@NotNull @NotNull ActionItem actionItem)
      Apply non-null fields from another ActionItem
      Parameters:
      actionItem - the action item to copy