Class ActionItem
java.lang.Object
io.github.projectunified.craftux.common.ActionItem
The action item
-
Constructor Summary
ConstructorsConstructorDescriptionCreate an emptyActionItem
ActionItem
(@NotNull ActionItem actionItem) Create a copy ofActionItem
ActionItem
(@NotNull ActionItem actionItem, boolean applyOnlyNonnull) Create a copy ofActionItem
-
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(@NotNull ActionItem actionItem) Apply non-null fields from anotherActionItem
void
callAction
(Object event) Call the action<E> void
extendAction
(Class<E> eventClass, BiConsumer<E, Consumer<Object>> operator) Extend the actionvoid
extendAction
(BiConsumer<Object, Consumer<Object>> operator) Extend the action<T> void
extendItem
(Class<T> itemClass, UnaryOperator<T> operator) Extend the item if it is of the given classvoid
extendItem
(UnaryOperator<Object> operator) Extend the itemGet the action@Nullable Object
getItem()
Get the item<T> T
Get the item as the given class, or null if it is not of that class<T> T
Get the item unchecked<E> void
Set the actionvoid
Set the actionvoid
Set the item
-
Constructor Details
-
ActionItem
public ActionItem()Create an emptyActionItem
-
ActionItem
Create a copy ofActionItem
- Parameters:
actionItem
- the action item to copyapplyOnlyNonnull
- if true, only non-null fields will be copied
-
ActionItem
Create a copy ofActionItem
- Parameters:
actionItem
- the action item to copy
-
-
Method Details
-
getItem
Get the item- Returns:
- the item
-
setItem
Set the item- Parameters:
item
- the item
-
extendItem
Extend the item- Parameters:
operator
- the operator to extend the item
-
extendItem
Extend the item if it is of the given class- Type Parameters:
T
- the item type- Parameters:
itemClass
- the class to checkoperator
- the operator to extend the item
-
getItem
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
Get the action- Returns:
- the action
-
setAction
Set the action- Parameters:
action
- the action
-
extendAction
Extend the action- Parameters:
operator
- the operator with the event and the old action
-
setAction
Set the action- Type Parameters:
E
- the event type- Parameters:
eventClass
- the event classaction
- the action
-
extendAction
Extend the action- Type Parameters:
E
- the event type- Parameters:
eventClass
- the event classoperator
- the operator with the event and the old action
-
callAction
Call the action- Parameters:
event
- the event
-
apply
Apply non-null fields from anotherActionItem
- Parameters:
actionItem
- the action item to copy
-