Class ConstrainedParameterTypeDecorator<S extends Source,T>
java.lang.Object
studio.mevera.imperat.util.TypeCapturer
studio.mevera.imperat.command.parameters.type.BaseParameterType<S,T>
studio.mevera.imperat.command.parameters.ConstrainedParameterTypeDecorator<S,T>
- All Implemented Interfaces:
ParameterType<S,T>
public final class ConstrainedParameterTypeDecorator<S extends Source,T>
extends BaseParameterType<S,T>
-
Field Summary
Fields inherited from class studio.mevera.imperat.command.parameters.type.BaseParameterType
suggestions, type -
Method Summary
Modifier and TypeMethodDescriptionbooleanequalsExactly(Type type) Checks if the given type exactly matches this parameter type.Returns the suggestion resolver associated with this parameter type.booleanisRelatedToType(Type type) Checks if the given type is related to this parameter type.booleanmatchesInput(int rawPosition, Context<S> context, CommandParameter<S> parameter) Determines whether the provided input matches the expected format or criteria for a given command parameter.static <S extends Source,T>
ConstrainedParameterTypeDecorator<S,T> of(ParameterType<S, T> original, Set<String> allowedValues) static <S extends Source,T>
ConstrainedParameterTypeDecorator<S,T> of(ParameterType<S, T> original, Set<String> allowedValues, boolean caseSensitive) resolve(@NotNull ExecutionContext<S> context, @NotNull CommandInputStream<S> commandInputStream, @NotNull String input) Resolves the parameter value from the given input string, using the provided execution context and input stream.@NotNull ParameterType<S,T> withSuggestions(String... suggestions) Adds the provided suggestions to the current list of suggestions for this parameter type.Gets aTypeWrapfor the handled type.Methods inherited from class studio.mevera.imperat.command.parameters.type.BaseParameterType
typeMethods inherited from class studio.mevera.imperat.util.TypeCapturer
extractType, extractTypeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface studio.mevera.imperat.command.parameters.type.ParameterType
getConsumedArguments, isGreedy, supplyDefaultValue
-
Method Details
-
of
public static <S extends Source,T> ConstrainedParameterTypeDecorator<S,T> of(ParameterType<S, T> original, Set<String> allowedValues, boolean caseSensitive) -
of
public static <S extends Source,T> ConstrainedParameterTypeDecorator<S,T> of(ParameterType<S, T> original, Set<String> allowedValues) -
resolve
@Nullable public T resolve(@NotNull @NotNull ExecutionContext<S> context, @NotNull @NotNull CommandInputStream<S> commandInputStream, @NotNull @NotNull String input) throws ImperatException Description copied from interface:ParameterTypeResolves the parameter value from the given input string, using the provided execution context and input stream.- Parameters:
context- the execution context.commandInputStream- the command input stream.input- the raw input string.- Returns:
- the resolved value, or
nullif resolution fails. - Throws:
ImperatException- if resolution fails due to an error.
-
getSuggestionResolver
Description copied from class:BaseParameterTypeReturns the suggestion resolver associated with this parameter type.- Specified by:
getSuggestionResolverin interfaceParameterType<S extends Source,T> - Overrides:
getSuggestionResolverin classBaseParameterType<S extends Source,T> - Returns:
- the suggestion resolver for generating suggestions based on the parameter type.
-
isRelatedToType
Description copied from interface:ParameterTypeChecks if the given type is related to this parameter type.- Parameters:
type- the type to check.- Returns:
trueif the types are related,falseotherwise.
-
equalsExactly
Description copied from interface:ParameterTypeChecks if the given type exactly matches this parameter type.- Parameters:
type- the type to check.- Returns:
trueif the types match exactly,falseotherwise.
-
wrappedType
Description copied from interface:ParameterTypeGets aTypeWrapfor the handled type.- Returns:
- the wrapped type.
-
matchesInput
Description copied from class:BaseParameterTypeDetermines whether the provided input matches the expected format or criteria for a given command parameter. this is used duringCommandTree.contextMatch(Context, ArgumentInput)- Specified by:
matchesInputin interfaceParameterType<S extends Source,T> - Overrides:
matchesInputin classBaseParameterType<S extends Source,T> - Parameters:
rawPosition- The raw position of the argument in the input.context- The context to be matched, providing necessary information about the command execution environment.parameter- The command parameter that provides context for the input handling.- Returns:
- true if the input matches the expected criteria; false otherwise.
-
withSuggestions
Description copied from class:BaseParameterTypeAdds the provided suggestions to the current list of suggestions for this parameter type.- Specified by:
withSuggestionsin interfaceParameterType<S extends Source,T> - Overrides:
withSuggestionsin classBaseParameterType<S extends Source,T> - Parameters:
suggestions- The array of suggestions to be added.- Returns:
- The current instance of the parameter type with the added suggestions.
-