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 givencomponent
as 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.void
Sets the executable command of this node.Returns the component contained in this node.boolean
getChild
(@NonNull CommandComponent<C> component) Returns the node containing the givencomponent
int
hashCode()
boolean
isLeaf()
Returns whether the node is a leaf nodenodeMeta()
Returns the node meta instanceparent()
Returns the parent nodevoid
parent
(@Nullable CommandNode<C> parent) Updates the parent nodeboolean
removeChild
(@NonNull CommandNode<C> child) Removes the givenchild
as a child from this nodevoid
Sorts 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 givencomponent
as 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 givenchild
as a child from this node- Parameters:
child
- the child to remove- Returns:
true
if the child node was removed,false
if not
-
isLeaf
public boolean isLeaf()Returns whether the node is a leaf node- Returns:
true
if 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
-