Record Class ParameterModel
java.lang.Object
java.lang.Record
io.github.projectunified.craftcommand.processor.model.ParameterModel
- Record Components:
name- the parameter nametype- the Java type of the parameterenumConstants- the constants when the type is an enum, otherwisenullgreedy- whether the parameter consumes all remaining argumentsoptional- whether the parameter has a default valuedefaultValue- the default value, ornullsuggestProvider- the suggestion provider name, ornullsuggestField- whether the suggestion provider names a fieldresolveName- the raw@Resolvevalue, ornullresolverMethod- the linked resolver method, ornullsuggestMethod- the linked suggestion method, ornullelement- 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 Summary
ConstructorsConstructorDescriptionParameterModel(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 aParameterModelrecord class. -
Method Summary
Modifier and TypeMethodDescriptionasOptional(String inheritedDefault) Creates an optional copy of this parameter using the default value of a parent parameter.Returns the value of thedefaultValuerecord component.element()Returns the value of theelementrecord component.Returns the value of theenumConstantsrecord component.final booleanIndicates whether some other object is "equal to" this one.booleangreedy()Returns the value of thegreedyrecord component.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.booleanoptional()Returns the value of theoptionalrecord component.Returns the value of theresolveNamerecord component.Returns the value of theresolverMethodrecord component.static ParameterModelsender(String name, TypeMirror type, String resolveName, MethodModel resolverMethod, VariableElement element) Creates the sender parameter, which has no command argument, default, or suggestion state.booleanReturns the value of thesuggestFieldrecord component.Returns the value of thesuggestMethodrecord component.Returns the value of thesuggestProviderrecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.Creates a copy of this parameter using the Java identifier as its name.
-
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 aParameterModelrecord class.- Parameters:
name- the value for thenamerecord componenttype- the value for thetyperecord componentenumConstants- the value for theenumConstantsrecord componentgreedy- the value for thegreedyrecord componentoptional- the value for theoptionalrecord componentdefaultValue- the value for thedefaultValuerecord componentsuggestProvider- the value for thesuggestProviderrecord componentsuggestField- the value for thesuggestFieldrecord componentresolveName- the value for theresolveNamerecord componentresolverMethod- the value for theresolverMethodrecord componentsuggestMethod- the value for thesuggestMethodrecord componentelement- the value for theelementrecord 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 nametype- the sender typeresolveName- the raw@ResolvevalueresolverMethod- the linked resolver method, ornullelement- the underlying sender element
-
withName
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
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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
enumConstants
Returns the value of theenumConstantsrecord component.- Returns:
- the value of the
enumConstantsrecord component
-
greedy
public boolean greedy()Returns the value of thegreedyrecord component.- Returns:
- the value of the
greedyrecord component
-
optional
public boolean optional()Returns the value of theoptionalrecord component.- Returns:
- the value of the
optionalrecord component
-
defaultValue
Returns the value of thedefaultValuerecord component.- Returns:
- the value of the
defaultValuerecord component
-
suggestProvider
Returns the value of thesuggestProviderrecord component.- Returns:
- the value of the
suggestProviderrecord component
-
suggestField
public boolean suggestField()Returns the value of thesuggestFieldrecord component.- Returns:
- the value of the
suggestFieldrecord component
-
resolveName
Returns the value of theresolveNamerecord component.- Returns:
- the value of the
resolveNamerecord component
-
resolverMethod
Returns the value of theresolverMethodrecord component.- Returns:
- the value of the
resolverMethodrecord component
-
suggestMethod
Returns the value of thesuggestMethodrecord component.- Returns:
- the value of the
suggestMethodrecord component
-
element
Returns the value of theelementrecord component.- Returns:
- the value of the
elementrecord component
-