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 Details

  • Constructor Details

    • CommandNode

      public CommandNode(@Nullable CommandComponent<C> component)
      Creates a new command node
      Parameters:
      component - the component contained in the node, or null
  • Method Details

    • children

      public @NonNull List<@NonNull CommandNode<C>> children()
      Returns an immutable view of the node's children
      Returns:
      list of children
    • addChild

      public @NonNull CommandNode<C> addChild(@NonNull CommandComponent<C> component)
      Adds the given component as a child of this node
      Parameters:
      component - the child component
      Returns:
      the node containing the given component
    • getChild

      public @Nullable CommandNode<C> getChild(@NonNull CommandComponent<C> component)
      Returns the node containing the given component
      Parameters:
      component - the child component
      Returns:
      the node containing the given component, or null
    • removeChild

      public boolean removeChild(@NonNull CommandNode<C> child)
      Removes the given child 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, else false
    • nodeMeta

      Returns the node meta instance
      Returns:
      Node meta
    • component

      public @MonotonicNonNull CommandComponent<C> component()
      Returns the component contained in this node.
      Returns:
      the component
    • command

      public @MonotonicNonNull Command<C> command()
      Returns the command that the component() belongs to, if the component() is executable.
      Returns:
      the command
    • command

      public void command(@NonNull Command<C> command)
      Sets the executable command of this node.
      Parameters:
      command - command
    • parent

      public @Nullable CommandNode<C> parent()
      Returns the parent node
      Returns:
      Parent node
    • parent

      public void parent(@Nullable CommandNode<C> parent)
      Updates the parent node
      Parameters:
      parent - new parent node
    • sortChildren

      public void sortChildren()
      Sorts the child nodes using their components.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object