A - The actor type. This allows for better type inference and
reduces the need for type-checking and castingpublic interface CommandNode<A extends CommandActor> extends java.lang.Comparable<CommandNode<A>>
LiteralNode
or a ParameterNode.LiteralNode,
ParameterNode| Modifier and Type | Method and Description |
|---|---|
@Nullable CommandAction<A> |
action()
Returns the action bound to this command node.
|
@NotNull ExecutableCommand<A> |
command()
Returns the
ExecutableCommand that this node
belongs to |
void |
execute(@NotNull ExecutionContext<A> context,
@NotNull MutableStringStream input)
Executes the
action() of this node with the given context and input. |
default boolean |
hasAction()
Tests whether this node has an
action(). |
boolean |
isLast()
Tests whether is this node the last one in the command tree
it belongs to
|
boolean |
isLiteral()
Tests whether this node is a
LiteralNode |
boolean |
isParameter()
Tests whether this node is a
ParameterNode |
@NotNull Lamp<A> |
lamp()
Returns the
Lamp instance that constructed this node |
@NotNull java.lang.String |
name()
Returns the name of this node.
|
@NotNull java.lang.String |
representation()
Returns the node string representation.
|
@NotNull LiteralNode<A> |
requireLiteralNode()
Requires this node to be a
LiteralNode and automatically
casts it, otherwise throws a IllegalStateException. |
<T> @NotNull ParameterNode<A,T> |
requireParameterNode()
Requires this node to be a
ParameterNode and automatically
casts it, otherwise throws a IllegalStateException. |
@NotNull @NotNull Lamp<A> lamp()
Lamp instance that constructed this node@NotNull @NotNull ExecutableCommand<A> command()
ExecutableCommand that this node
belongs to@NotNull @NotNull java.lang.String name()
@Nullable @Contract(pure=true) @Nullable CommandAction<A> action()
null if none
is registered.boolean isLast()
default boolean hasAction()
action().void execute(@NotNull
@NotNull ExecutionContext<A> context,
@NotNull
@NotNull MutableStringStream input)
action() of this node with the given context and input.
If this node has no action, this method does nothing.
context - The execution contextinput - The user inputboolean isLiteral()
LiteralNode@NotNull @NotNull LiteralNode<A> requireLiteralNode()
LiteralNode and automatically
casts it, otherwise throws a IllegalStateException.java.lang.IllegalStateException - if this is not a literal nodeboolean isParameter()
ParameterNode@NotNull <T> @NotNull ParameterNode<A,T> requireParameterNode()
ParameterNode and automatically
casts it, otherwise throws a IllegalStateException.java.lang.IllegalStateException - if this is not a parameter node@NotNull @NotNull java.lang.String representation()
<name> if it's a required parameter[name] if it's an optional parameter