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

public class ParameterModel extends Object
Model representing a command method parameter.

All annotation-derived facts are resolved once at parse time: the resolver declared by @Resolve and the suggestion provider declared by @Suggest are linked here, so code generation never re-reads annotations from the parameter element.

  • Constructor Details

    • ParameterModel

      public ParameterModel(String name, TypeMirror type, boolean greedy, boolean optional, String defaultValue, String suggestProvider, String resolveName, MethodModel resolverMethod, MethodModel suggestMethod, VariableElement element)
      Constructs a ParameterModel.
      Parameters:
      name - the parameter name (from @Name or reflection)
      type - the Java type of the parameter
      greedy - true if marked with @Greedy
      optional - true if marked with @Default
      defaultValue - the default value string when optional, or null
      suggestProvider - the custom suggest provider name, or null
      resolveName - the raw @Resolve value, null when @Resolve is absent and empty when it is present without a resolver name
      resolverMethod - the resolver method model referenced by a named @Resolve, or null
      suggestMethod - the suggest provider method model when @Suggest names a valid method, or null when absent, a field, or an invalid signature
      element - the underlying VariableElement
  • Method Details

    • getName

      public String getName()
      Gets the parameter name.
      Returns:
      the parameter name
    • getType

      public TypeMirror getType()
      Gets the Java TypeMirror of this parameter.
      Returns:
      the parameter type
    • isGreedy

      public boolean isGreedy()
      Checks if this parameter is greedy.
      Returns:
      true if greedy
    • isOptional

      public boolean isOptional()
      Checks if this parameter is optional.
      Returns:
      true if optional
    • getDefaultValue

      public String getDefaultValue()
      Gets the default value string.
      Returns:
      the default value, or null
    • getSuggestProvider

      public String getSuggestProvider()
      Gets the custom suggestion provider name.
      Returns:
      the suggestion provider name, or null
    • getResolveName

      public String getResolveName()
      Gets the raw @Resolve value of this parameter.
      Returns:
      the resolver name, null when @Resolve is absent, empty when present without a name
    • getResolverMethod

      public MethodModel getResolverMethod()
      Gets the resolver method linked by a named @Resolve.
      Returns:
      the resolver method model, or null when there is no named resolver
    • getSuggestMethod

      public MethodModel getSuggestMethod()
      Gets the suggest provider method linked by @Suggest.
      Returns:
      the suggest method model, or null when there is none
    • getElement

      public VariableElement getElement()
      Gets the underlying VariableElement.
      Returns:
      the variable element
    • withName

      public ParameterModel withName(String name)
      Creates a copy of this parameter using the Java identifier as its name.

      Used when handing the parameter to SPI handlers, which report source-level parameter names.

      Parameters:
      name - the replacement name
      Returns:
      a parameter model with the given name
    • asOptional

      public ParameterModel asOptional(String inheritedDefault)
      Creates an optional copy of this parameter using the default value of a parent parameter.
      Parameters:
      inheritedDefault - the default value inherited from the parent parameter
      Returns:
      a parameter model marked optional with the inherited default