Package org.incendo.cloud.internal
Class CommandNode<C>
java.lang.Object
org.incendo.cloud.internal.CommandNode<C>
- Type Parameters:
C- command sender type
@API(status=INTERNAL,
consumers="org.incendo.cloud.*")
public final class CommandNode<C>
extends Object
Very simple tree structure
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCommandNode(@Nullable CommandComponent<C> component) Creates a new command node -
Method Summary
Modifier and TypeMethodDescriptionaddChild(@NonNull CommandComponent<C> component) Adds the givencomponentas a child of this nodechildren()Returns an immutable view of the node's childrencommand()Returns the command that thecomponent()belongs to, if thecomponent()is executable.voidSets the executable command of this node.Returns the component contained in this node.booleangetChild(@NonNull CommandComponent<C> component) Returns the node containing the givencomponentinthashCode()booleanisLeaf()Returns whether the node is a leaf nodenodeMeta()Returns the node meta instanceparent()Returns the parent nodevoidparent(@Nullable CommandNode<C> parent) Updates the parent nodebooleanremoveChild(@NonNull CommandNode<C> child) Removes the givenchildas a child from this nodevoidSorts the child nodes using theircomponents.toString()
-
Field Details
-
META_KEY_SENDER_TYPES
-
META_KEY_ACCESS
-
-
Constructor Details
-
CommandNode
Creates a new command node- Parameters:
component- the component contained in the node, ornull
-
-
Method Details
-
children
Returns an immutable view of the node's children- Returns:
- list of children
-
addChild
Adds the givencomponentas a child of this node- Parameters:
component- the child component- Returns:
- the node containing the given
component
-
getChild
Returns the node containing the givencomponent- Parameters:
component- the child component- Returns:
- the node containing the given
component, ornull
-
removeChild
Removes the givenchildas a child from this node- Parameters:
child- the child to remove- Returns:
trueif the child node was removed,falseif not
-
isLeaf
public boolean isLeaf()Returns whether the node is a leaf node- Returns:
trueif the node is a leaf node, elsefalse
-
nodeMeta
Returns the node meta instance- Returns:
- Node meta
-
component
Returns the component contained in this node.- Returns:
- the component
-
command
Returns the command that thecomponent()belongs to, if thecomponent()is executable.- Returns:
- the command
-
command
Sets the executable command of this node.- Parameters:
command- command
-
parent
Returns the parent node- Returns:
- Parent node
-
parent
Updates the parent node- Parameters:
parent- new parent node
-
sortChildren
public void sortChildren()Sorts the child nodes using theircomponents. -
equals
-
hashCode
public int hashCode() -
toString
-