java.lang.Object
io.github.projectunified.craftcommand.processor.model.CommandModel

public class CommandModel extends Object
Model representing a parsed command or subcommand class.

Nested subcommand models are indexed by their class element on construction, so the model of any class in the command tree is resolved by a direct lookup instead of a tree walk.

  • Constructor Details

    • CommandModel

      public CommandModel(com.palantir.javapoet.ClassName className, String packageName, String commandName, List<String> aliases, String description, MethodModel defaultMethod, List<MethodModel> subcommands, List<CommandModel> nestedSubcommands, TypeElement element)
      Creates a command model and indexes its nested subcommands.
      Parameters:
      className - the generated class name
      packageName - the generated package name
      commandName - the primary command name
      aliases - the command aliases
      description - the command description
      defaultMethod - the default action, or null
      subcommands - the method-level subcommands
      nestedSubcommands - the class-level subcommands
      element - the underlying command class element
  • Method Details

    • getClassName

      public com.palantir.javapoet.ClassName getClassName()
      Gets the ClassName of the command class.
      Returns:
      the class name
    • getPackageName

      public String getPackageName()
      Gets the package name of the command class.
      Returns:
      the package name
    • getCommandName

      public String getCommandName()
      Gets the primary name of the command.
      Returns:
      the command name
    • getAliases

      public List<String> getAliases()
      Gets the aliases of the command.
      Returns:
      the list of aliases
    • getDescription

      public String getDescription()
      Gets the command description.
      Returns:
      the description
    • getDefaultMethod

      public MethodModel getDefaultMethod()
      Gets the default execution method.
      Returns:
      the default method model, or null if none
    • getSubcommands

      public List<MethodModel> getSubcommands()
      Gets the method-level subcommands.
      Returns:
      the list of subcommands
    • getNestedSubcommands

      public List<CommandModel> getNestedSubcommands()
      Gets the nested class-level subcommands.
      Returns:
      the list of nested subcommands
    • getElement

      public TypeElement getElement()
      Gets the underlying Java TypeElement of this class.
      Returns:
      the type element
    • getNestedIndex

      public Map<TypeElement,CommandModel> getNestedIndex()
      Gets this model and every nested subcommand model indexed by their class element.
      Returns:
      map of class element to command model
    • findModel

      public CommandModel findModel(TypeElement targetClass)
      Finds the model of a class within this command tree.
      Parameters:
      targetClass - the class element to look up
      Returns:
      the matching model, or null if the class is not part of this tree