Record Class ParameterModel

java.lang.Object
java.lang.Record
io.github.projectunified.craftcommand.processor.model.ParameterModel
Record Components:
name - the parameter name
type - the Java type of the parameter
enumConstants - the constants when the type is an enum, otherwise null
greedy - whether the parameter consumes all remaining arguments
optional - whether the parameter has a default value
defaultValue - the default value, or null
suggestProvider - the suggestion provider name, or null
suggestField - whether the suggestion provider names a field
resolveName - the raw @Resolve value, or null
resolverMethod - the linked resolver method, or null
suggestMethod - the linked suggestion method, or null
element - the underlying parameter element

public record ParameterModel(String name, TypeMirror type, List<String> enumConstants, boolean greedy, boolean optional, String defaultValue, String suggestProvider, boolean suggestField, String resolveName, MethodModel resolverMethod, MethodModel suggestMethod, VariableElement element) extends Record
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 the core command annotations. SPI handlers still read their own annotations.

  • Constructor Details

    • ParameterModel

      public ParameterModel(String name, TypeMirror type, List<String> enumConstants, boolean greedy, boolean optional, String defaultValue, String suggestProvider, boolean suggestField, String resolveName, MethodModel resolverMethod, MethodModel suggestMethod, VariableElement element)
      Creates an instance of a ParameterModel record class.
      Parameters:
      name - the value for the name record component
      type - the value for the type record component
      enumConstants - the value for the enumConstants record component
      greedy - the value for the greedy record component
      optional - the value for the optional record component
      defaultValue - the value for the defaultValue record component
      suggestProvider - the value for the suggestProvider record component
      suggestField - the value for the suggestField record component
      resolveName - the value for the resolveName record component
      resolverMethod - the value for the resolverMethod record component
      suggestMethod - the value for the suggestMethod record component
      element - the value for the element record component
  • Method Details

    • sender

      public static ParameterModel sender(String name, TypeMirror type, String resolveName, MethodModel resolverMethod, VariableElement element)
      Creates the sender parameter, which has no command argument, default, or suggestion state.
      Parameters:
      name - the sender parameter name
      type - the sender type
      resolveName - the raw @Resolve value
      resolverMethod - the linked resolver method, or null
      element - the underlying sender 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
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • type

      public TypeMirror type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • enumConstants

      public List<String> enumConstants()
      Returns the value of the enumConstants record component.
      Returns:
      the value of the enumConstants record component
    • greedy

      public boolean greedy()
      Returns the value of the greedy record component.
      Returns:
      the value of the greedy record component
    • optional

      public boolean optional()
      Returns the value of the optional record component.
      Returns:
      the value of the optional record component
    • defaultValue

      public String defaultValue()
      Returns the value of the defaultValue record component.
      Returns:
      the value of the defaultValue record component
    • suggestProvider

      public String suggestProvider()
      Returns the value of the suggestProvider record component.
      Returns:
      the value of the suggestProvider record component
    • suggestField

      public boolean suggestField()
      Returns the value of the suggestField record component.
      Returns:
      the value of the suggestField record component
    • resolveName

      public String resolveName()
      Returns the value of the resolveName record component.
      Returns:
      the value of the resolveName record component
    • resolverMethod

      public MethodModel resolverMethod()
      Returns the value of the resolverMethod record component.
      Returns:
      the value of the resolverMethod record component
    • suggestMethod

      public MethodModel suggestMethod()
      Returns the value of the suggestMethod record component.
      Returns:
      the value of the suggestMethod record component
    • element

      public VariableElement element()
      Returns the value of the element record component.
      Returns:
      the value of the element record component