Class ParameterOptional<S extends Source,T>
java.lang.Object
studio.mevera.imperat.util.TypeCapturer
studio.mevera.imperat.command.parameters.type.BaseParameterType<S,Optional<T>>
studio.mevera.imperat.command.parameters.type.ParameterOptional<S,T>
- All Implemented Interfaces:
ParameterType<S,Optional<T>>
-
Field Summary
Fields inherited from class studio.mevera.imperat.command.parameters.type.BaseParameterType
suggestions, type -
Constructor Summary
ConstructorsConstructorDescriptionParameterOptional(TypeWrap<Optional<T>> typeWrap, ParameterType<S, T> typeResolver) -
Method Summary
Modifier and TypeMethodDescriptionReturns the suggestion resolver associated with this parameter type.booleanisGreedy(CommandParameter<S> parameter) Determines if this parameter type is greedy, meaning it consumes multiple arguments.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.resolve(@NotNull ExecutionContext<S> context, @NotNull CommandInputStream<S> inputStream, @NotNull String input) Resolves the parameter value from the given input string, using the provided execution context and input stream.Returns the default value supplier for the given source and command parameter.Methods inherited from class studio.mevera.imperat.command.parameters.type.BaseParameterType
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
equalsExactly, getConsumedArguments, isRelatedToType, wrappedType
-
Constructor Details
-
ParameterOptional
-
-
Method Details
-
resolve
@NotNull public @NotNull Optional<T> resolve(@NotNull @NotNull ExecutionContext<S> context, @NotNull @NotNull CommandInputStream<S> inputStream, @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.inputStream- 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,Optional<T>> - Returns:
- the suggestion resolver for generating suggestions based on the parameter 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,Optional<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.
-
supplyDefaultValue
Description copied from interface:ParameterTypeReturns the default value supplier for the given source and command parameter. By default, this returns an empty supplier, indicating no default value.- Returns:
- an
OptionalValueSupplierproviding the default value, or empty if none.
-
isGreedy
Description copied from interface:ParameterTypeDetermines if this parameter type is greedy, meaning it consumes multiple arguments. By default, returnsfalse.- Parameters:
parameter- the command parameter.- Returns:
trueif greedy,falseotherwise.
-