Class InputParameter<S extends Source>
java.lang.Object
studio.mevera.imperat.command.parameters.InputParameter<S>
- All Implemented Interfaces:
DescriptionHolder,CommandParameter<S>,PermissionHolder
- Direct Known Subclasses:
AnnotationParameterDecorator,FlagCommandParameter,NumericParameterDecorator
@Internal
public abstract class InputParameter<S extends Source>
extends Object
implements CommandParameter<S>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Descriptionprotected final booleanprotected Stringprotected final booleanprotected intprotected final Stringprotected final booleanprotected final OptionalValueSupplierprotected Stringprotected final SuggestionResolver<S>protected final ParameterType<S,?> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInputParameter(String name, @NotNull ParameterType<S, ?> type, @Nullable String permission, Description description, boolean optional, boolean flag, boolean greedy, @NotNull OptionalValueSupplier optionalValueSupplier, @Nullable SuggestionResolver<S> suggestionResolver) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPermission(String permission) Adds a permission for this holder.Casts the parameter to a subcommand/commandCasts the parameter to a flag parametervoiddescribe(Description description) Sets the description for this entity.Retrieves the current description associated with this entity.booleanformat()Formats the usage parameter, the default value is the name of the parameter@NotNull OptionalValueSupplierThe permission for this parameter@Nullable StringFor parameters, ONLY one permission is allowed for each parameter.@Nullable SuggestionResolver<S>Fetches the suggestion resolver linked to this command parameter.inthashCode()booleanisFlag()booleanisGreedy()booleanbooleanname()parent()voidSets parent command for a parameterintposition()voidposition(int position) Sets the position of this parameter in a syntax DO NOT USE THIS FOR ANY REASON unless it's necessary to do sofinal voidSets a custom format for this parameter the default value is the name of the parametervoidsetSinglePermission(String permission) booleansimilarTo(CommandParameter<?> parameter) Checks if this parameter has same name and valueType to the otherCommandParameterunlike `CommandParameter#equals(Object)`, if both parameters are only different in their parentCommand, it would still return truetoString()@NotNull ParameterType<S,?> type()Retrieves the parameter type associated with this command parameter.TypeWrap<?>Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface studio.mevera.imperat.command.parameters.CommandParameter
asAnnotated, asNumeric, copyWithDifferentPosition, isAnnotated, isCommand, isNumeric, isRequired, valueTypeMethods inherited from interface studio.mevera.imperat.command.DescriptionHolder
describeMethods inherited from interface studio.mevera.imperat.command.PermissionHolder
hasPermission
-
Field Details
-
parentCommand
-
name
-
format
-
type
-
optional
protected final boolean optional -
flag
protected final boolean flag -
greedy
protected final boolean greedy -
optionalValueSupplier
-
suggestionResolver
-
permission
-
description
-
index
protected int index
-
-
Constructor Details
-
InputParameter
protected InputParameter(String name, @NotNull @NotNull ParameterType<S, ?> type, @Nullable @Nullable String permission, Description description, boolean optional, boolean flag, boolean greedy, @NotNull @NotNull OptionalValueSupplier optionalValueSupplier, @Nullable @Nullable SuggestionResolver<S> suggestionResolver)
-
-
Method Details
-
name
- Specified by:
namein interfaceCommandParameter<S extends Source>- Returns:
- the name of the parameter
-
format
Description copied from interface:CommandParameterFormats the usage parameter, the default value is the name of the parameter- Specified by:
formatin interfaceCommandParameter<S extends Source>- Returns:
- the formatted parameter
- See Also:
-
setFormat
Description copied from interface:CommandParameterSets a custom format for this parameter the default value is the name of the parameter- Specified by:
setFormatin interfaceCommandParameter<S extends Source>- Parameters:
format- the format to set- See Also:
-
parent
- Specified by:
parentin interfaceCommandParameter<S extends Source>- Returns:
- the parent of this parameter
-
parent
Description copied from interface:CommandParameterSets parent command for a parameter- Specified by:
parentin interfaceCommandParameter<S extends Source>- Parameters:
parentCommand- the parameter's owning command
-
position
public int position()- Specified by:
positionin interfaceCommandParameter<S extends Source>- Returns:
- the index of this parameter
-
position
public void position(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:
positionin interfaceCommandParameter<S extends Source>- Parameters:
position- the position to set
-
type
Description copied from interface:CommandParameterRetrieves the parameter type associated with this command parameter.- Specified by:
typein interfaceCommandParameter<S extends Source>- Returns:
- the
ParameterTypeof the command parameter
-
wrappedType
- Specified by:
wrappedTypein interfaceCommandParameter<S extends Source>- Returns:
- the value valueType-token of this parameter
-
getSinglePermission
Description copied from interface:CommandParameterFor parameters, ONLY one permission is allowed for each parameter.- Specified by:
getSinglePermissionin interfaceCommandParameter<S extends Source>- Returns:
- the single permission for this parameter.
-
setSinglePermission
- Specified by:
setSinglePermissionin interfaceCommandParameter<S extends Source>
-
getPermissions
The permission for this parameter- Specified by:
getPermissionsin interfacePermissionHolder- Returns:
- the parameter permission
-
addPermission
Description copied from interface:PermissionHolderAdds a permission for this holder.- Specified by:
addPermissionin interfacePermissionHolder- Parameters:
permission- the permission string to add, can benull.
-
getDefaultValueSupplier
- Specified by:
getDefaultValueSupplierin interfaceCommandParameter<S extends Source>- 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 interfaceCommandParameter<S extends Source>- Returns:
- whether this is an optional argument
-
isFlag
public boolean isFlag()- Specified by:
isFlagin interfaceCommandParameter<S extends Source>- Returns:
- checks whether this parameter is a flag
-
asFlagParameter
Casts the parameter to a flag parameter- Specified by:
asFlagParameterin interfaceCommandParameter<S extends Source>- Returns:
- the parameter as a flag
-
isGreedy
public boolean isGreedy()- Specified by:
isGreedyin interfaceCommandParameter<S extends Source>- Returns:
- checks whether this parameter consumes all the args input after it.
-
isGreedyString
public boolean isGreedyString()- Specified by:
isGreedyStringin interfaceCommandParameter<S extends Source>
-
asCommand
Description copied from interface:CommandParameterCasts the parameter to a subcommand/command- Specified by:
asCommandin interfaceCommandParameter<S extends Source>- Returns:
- the parameter as a command
-
getSuggestionResolver
Fetches the suggestion resolver linked to this command parameter.- Specified by:
getSuggestionResolverin interfaceCommandParameter<S extends Source>- Returns:
- the
SuggestionResolverfor a resolving suggestion
-
description
Description copied from interface:DescriptionHolderRetrieves the current description associated with this entity.- Specified by:
descriptionin interfaceDescriptionHolder- Returns:
- the current
Description.
-
describe
Description copied from interface:DescriptionHolderSets the description for this entity.- Specified by:
describein interfaceDescriptionHolder- Parameters:
description- theDescriptionto set.
-
similarTo
Description copied from interface:CommandParameterChecks if this parameter has same name and valueType to the otherCommandParameterunlike `CommandParameter#equals(Object)`, if both parameters are only different in their parentCommand, it would still return true- Specified by:
similarToin interfaceCommandParameter<S extends Source>- Parameters:
parameter- the parameter to compare to- Returns:
- Whether this parameter has same name and valueType to the other
CommandParameteror not
-
equals
-
hashCode
public int hashCode() -
toString
-