Class CommandTree<C>

  • Type Parameters:
    C - Command sender type

    public final class CommandTree<C>
    extends Object
    Tree containing all commands and command paths.

    All commands consists of unique paths made out of arguments. These arguments may be literals or variables. Command may either be required or optional, with the requirement that no optional argument precedes a required argument.

    The commands are stored in this tree and the nodes of tree consists of the command arguments. Each leaf node of the tree should containing a fully parsed Command. It is thus possible to walk the tree and determine whether or not the supplied input from a command sender constitutes a proper command.

    When parsing input, the tree will be walked until one of four scenarios occur:

    1. The input queue is empty at a non-leaf node
    2. The input queue is not empty following a leaf node
    3. No child node is able to accept the input
    4. The input queue is empty following a leaf node

    Scenarios one and two would result in a InvalidSyntaxException being thrown, whereas scenario three would result in a NoSuchCommandException if occurring at the root node or a InvalidSyntaxException otherwise. Only the fourth scenario would result in a complete command being parsed.