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.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.Gets aTypeWrapfor the handled type.Methods inherited from class studio.mevera.imperat.command.parameters.type.BaseParameterType
matchesInput, type, withSuggestionsMethods 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.
-