Class InputArgument<S extends CommandSource>
java.lang.Object
studio.mevera.imperat.command.arguments.InputArgument<S>
- All Implemented Interfaces:
Argument<S>,DescriptionHolder,PermissionHolder
- Direct Known Subclasses:
AnnotationArgumentDecorator,FlagArgumentImpl,NumericArgumentDecorator
@Internal
public abstract class InputArgument<S extends CommandSource>
extends Object
implements Argument<S>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DefaultValueProviderprotected Descriptionprotected final booleanprotected Stringprotected final booleanprotected intprotected final Stringprotected final booleanprotected PermissionsDataprotected final SuggestionProvider<S>protected final ArgumentType<S,?> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInputArgument(String name, @NotNull ArgumentType<S, ?> type, @NotNull PermissionsData permissionsData, Description description, boolean optional, boolean flag, boolean greedy, @NotNull DefaultValueProvider defaultValueProvider, @Nullable SuggestionProvider<S> suggestionProvider) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValidator(@NotNull ArgValidator<S> validator) Casts the parameter to a subcommand/commandCasts the parameter to a flag parametervoiddescribe(Description description) Sets the description for this entity.booleanformat()Formats the usage parameter, the default value is the name of the parameter@NotNull DefaultValueProviderRetrieves the current description associated with this entity.getName()@NotNull PermissionsDataint@Nullable SuggestionProvider<S>Fetches the suggestion resolver linked to this command parameter.@NotNull PriorityList<ArgValidator<S>>inthashCode()booleanisFlag()booleanisGreedy()booleanbooleanfinal voidSets a custom format for this parameter the default value is the name of the parametervoidSets parent command for a parametervoidsetPermissionData(@NotNull PermissionsData permission) voidsetPosition(int position) Sets the position of this parameter in a syntax DO NOT USE THIS FOR ANY REASON unless it's necessary to do sobooleantoString()@NotNull ArgumentType<S,?> type()Retrieves the parameter type associated with this command parameter.voidvalidate(ExecutionContext<S> context, ParsedArgument<S> parsedArgument) TypeWrap<?>Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface studio.mevera.imperat.command.arguments.Argument
asAnnotatedArgument, asNumeric, greedyLimit, isAnnotated, isCommand, isNumeric, isRequired, valueTypeMethods inherited from interface studio.mevera.imperat.command.DescriptionHolder
describeMethods inherited from interface studio.mevera.imperat.permissions.PermissionHolder
getPrimaryPermission
-
Field Details
-
name
-
type
-
optional
protected final boolean optional -
flag
protected final boolean flag -
greedy
protected final boolean greedy -
defaultValueProvider
-
suggestionProvider
-
parentCommand
-
format
-
permissionsData
-
description
-
index
protected int index
-
-
Constructor Details
-
InputArgument
protected InputArgument(String name, @NotNull @NotNull ArgumentType<S, ?> type, @NotNull @NotNull PermissionsData permissionsData, Description description, boolean optional, boolean flag, boolean greedy, @NotNull @NotNull DefaultValueProvider defaultValueProvider, @Nullable @Nullable SuggestionProvider<S> suggestionProvider)
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceArgument<S extends CommandSource>- Returns:
- the name of the parameter
-
format
Description copied from interface:ArgumentFormats the usage parameter, the default value is the name of the parameter- Specified by:
formatin interfaceArgument<S extends CommandSource>- Returns:
- the formatted parameter
- See Also:
-
setFormat
Description copied from interface:ArgumentSets a custom format for this parameter the default value is the name of the parameter- Specified by:
setFormatin interfaceArgument<S extends CommandSource>- Parameters:
format- the format to set- See Also:
-
getParent
- Specified by:
getParentin interfaceArgument<S extends CommandSource>- Returns:
- the parent of this parameter
-
setParent
Description copied from interface:ArgumentSets parent command for a parameter- Specified by:
setParentin interfaceArgument<S extends CommandSource>- Parameters:
parentCommand- the parameter's owning command
-
getPosition
public int getPosition()- Specified by:
getPositionin interfaceArgument<S extends CommandSource>- Returns:
- the index of this parameter
-
setPosition
public void setPosition(int position) Sets the position of this parameter in a syntax DO NOT USE THIS FOR ANY REASON unless it's necessary to do so- Specified by:
setPositionin interfaceArgument<S extends CommandSource>- Parameters:
position- the position to set
-
type
Description copied from interface:ArgumentRetrieves the parameter type associated with this command parameter.- Specified by:
typein interfaceArgument<S extends CommandSource>- Returns:
- the
ArgumentTypeof the command parameter
-
wrappedType
- Specified by:
wrappedTypein interfaceArgument<S extends CommandSource>- Returns:
- the value valueType-token of this parameter
-
getPermissionsData
- Specified by:
getPermissionsDatain interfacePermissionHolder
-
setPermissionData
- Specified by:
setPermissionDatain interfacePermissionHolder
-
getDefaultValueSupplier
- Specified by:
getDefaultValueSupplierin interfaceArgument<S extends CommandSource>- Returns:
- the default value if it's input is not present in case of the parameter being optional
-
isOptional
public boolean isOptional()- Specified by:
isOptionalin interfaceArgument<S extends CommandSource>- Returns:
- whether this is an optional argument
-
isFlag
public boolean isFlag()- Specified by:
isFlagin interfaceArgument<S extends CommandSource>- Returns:
- checks whether this parameter is a flag
-
asFlagParameter
Casts the parameter to a flag parameter- Specified by:
asFlagParameterin interfaceArgument<S extends CommandSource>- Returns:
- the parameter as a flag
-
isGreedy
public boolean isGreedy()- Specified by:
isGreedyin interfaceArgument<S extends CommandSource>- Returns:
- checks whether this parameter consumes all the args input after it.
-
isGreedyString
public boolean isGreedyString()- Specified by:
isGreedyStringin interfaceArgument<S extends CommandSource>
-
asCommand
Description copied from interface:ArgumentCasts the parameter to a subcommand/command- Specified by:
asCommandin interfaceArgument<S extends CommandSource>- Returns:
- the parameter as a command
-
getSuggestionResolver
Fetches the suggestion resolver linked to this command parameter.- Specified by:
getSuggestionResolverin interfaceArgument<S extends CommandSource>- Returns:
- the
SuggestionProviderfor a resolving suggestion
-
getDescription
Description copied from interface:DescriptionHolderRetrieves the current description associated with this entity.- Specified by:
getDescriptionin interfaceDescriptionHolder- Returns:
- the current
Description.
-
describe
Description copied from interface:DescriptionHolderSets the description for this entity.- Specified by:
describein interfaceDescriptionHolder- Parameters:
description- theDescriptionto set.
-
addValidator
- Specified by:
addValidatorin interfaceArgument<S extends CommandSource>
-
getValidators
- Specified by:
getValidatorsin interfaceArgument<S extends CommandSource>
-
validate
public void validate(ExecutionContext<S> context, ParsedArgument<S> parsedArgument) throws CommandException - Specified by:
validatein interfaceArgument<S extends CommandSource>- Throws:
CommandException
-
similarTo
Description copied from interface:ArgumentChecks if this parameter has same name and valueType to the otherArgumentunlike `Argument#equals(Object)`, if both parameters are only different in their parentCommand, it would still return true- Specified by:
similarToin interfaceArgument<S extends CommandSource>- Parameters:
parameter- the parameter to compare to- Returns:
- Whether this parameter has same name and valueType to the other
Argumentor not
-
equals
-
hashCode
public int hashCode() -
toString
-