Package revxrsal.commands.command
Interface CommandParameter
- All Superinterfaces:
CommandAnnotationHolder
,Comparable<CommandParameter>
,PermissionHolder
public interface CommandParameter
extends Comparable<CommandParameter>, PermissionHolder, CommandAnnotationHolder
Represents a parameter in a command method. This corresponds to
a
Parameter
in a method.
Note: this class has a natural ordering that is inconsistent with equals.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether should this parameter consume all arguments that come after it.@NotNull CommandHandler
Returns the command handler that instantiated this parameterint
Returns the actual index of the parameter in the command.@NotNull ExecutableCommand
Returns the command that declares this parameterboolean
Returns the defaultSwitch.defaultValue()
if the switch was not provided in the command.The default value.@Nullable String
Returns the description of this parameter.@NotNull String
Returns the name of the flag.@NotNull Type
Returns the full type of this parameter.Returns the Java-counterpart parameter of thisint
Returns the index of this parameter in the method.@NotNull String
getName()
Returns the parameter name, either from the@Named
annotation or the compiler-reserved name 'argN'.@NotNull CommandPermission
Returns the required permission to access this parameter.<T> @NotNull ParameterResolver<T>
Returns the resolver for this parameter.@NotNull SuggestionProvider
Returns theSuggestionProvider
of this parameter.@NotNull String
Returns the name of the switch.@NotNull Class<?>
getType()
The runtime-present type of this parameter@NotNull @Unmodifiable List<ParameterValidator<Object>>
Returns all the validators of the parameterboolean
isFlag()
Returns whether is this parameter aFlag
parameter or notboolean
Returns whether this parameter is the last in the methodboolean
Whether is this parameter optional or not.boolean
isSwitch()
Returns whether is this parameter aSwitch
parameter or not.Methods inherited from interface revxrsal.commands.command.trait.CommandAnnotationHolder
getAnnotation, hasAnnotation
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface revxrsal.commands.command.trait.PermissionHolder
checkPermission, hasPermission
-
Method Details
-
getName
Returns the parameter name, either from the@Named
annotation or the compiler-reserved name 'argN'.- Returns:
- The parameter name
- See Also:
-
getDescription
Returns the description of this parameter. This can be specified withDescription
.This may be leveraged by some platforms for completions or suggestions.
- Returns:
- The parameter description.
- See Also:
-
getMethodIndex
int getMethodIndex()Returns the index of this parameter in the method.- Returns:
- The index of this parameter
-
getCommandIndex
int getCommandIndex()Returns the actual index of the parameter in the command.If this parameter does not
ParameterResolver.mutatesArguments()
, this will return -1.- Returns:
- The command index
-
getType
The runtime-present type of this parameter- Returns:
- The parameter type
-
getFullType
Returns the full type of this parameter. For example, if this is aList<String>
then this will return that full type.- Returns:
- The full type, including generics.
-
getDefaultValue
The default value. This is set when annotated byDefault
.- Returns:
- The parameter's default value
-
consumesAllString
boolean consumesAllString()Whether should this parameter consume all arguments that come after it.This will return
true
if, and only if this is the last parameter in the method and is annotated withSingle
.- Returns:
- Whether should this parameter consume all arguments
-
getJavaParameter
Parameter getJavaParameter()Returns the Java-counterpart parameter of this- Returns:
- The reflection parameter
-
getSuggestionProvider
Returns theSuggestionProvider
of this parameter. If not specified, this will returnSuggestionProvider.EMPTY
.- Returns:
- The parameter's suggestion provider.
-
getValidators
Returns all the validators of the parameter- Returns:
- The parameter validators
-
isOptional
boolean isOptional()Whether is this parameter optional or not. This is whether the parameter has theOptional
annotation or not- Returns:
- Whether is this parameter optional
-
isLastInMethod
boolean isLastInMethod()Returns whether this parameter is the last in the method- Returns:
- If this parameter is the last in method
-
isSwitch
boolean isSwitch()Returns whether is this parameter aSwitch
parameter or not.- Returns:
- Whether is this parameter a switch or not
-
getSwitchName
Returns the name of the switch. Returns null ifisSwitch()
is false.- Returns:
- The switch name, otherwise throws a
IllegalStateException
- Throws:
IllegalStateException
- If this parameter is not a switch
-
isFlag
boolean isFlag()Returns whether is this parameter aFlag
parameter or not- Returns:
- Whether is this parameter a flag or not
-
getFlagName
Returns the name of the flag. Returns null ifisFlag()
is false.- Returns:
- The flag name, otherwise throws a
IllegalStateException
- Throws:
IllegalStateException
- If this parameter is not a switch
-
getDefaultSwitch
boolean getDefaultSwitch()Returns the defaultSwitch.defaultValue()
if the switch was not provided in the command.Note that this will return
false
ifisSwitch()
isfalse
.- Returns:
- The default switch value.
-
getResolver
Returns the resolver for this parameter. SeeParameterResolver
for more information.- Returns:
- The resolver
- See Also:
-
getCommandHandler
Returns the command handler that instantiated this parameter- Returns:
- The owning command handler
-
getDeclaringCommand
Returns the command that declares this parameter- Returns:
- The declaring command for this parameter
- Since:
- 1.3.0
-
getPermission
Returns the required permission to access this parameter.Parameters by default inherit their parent
getDeclaringCommand()
permission, unless- Specified by:
getPermission
in interfacePermissionHolder
- Returns:
- The command permission
-