Interface ArgumentParser.FutureArgumentParser<C,T>
- Type Parameters:
C- the command sender typeT- the type produced by the parser
- All Superinterfaces:
ArgumentParser<C,,T> SuggestionProviderHolder<C>
- All Known Subinterfaces:
AggregateParser<C,O>
- All Known Implementing Classes:
CommandFlagParser,EitherParser,MappedArgumentParserImpl
- Enclosing interface:
ArgumentParser<C,T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
ArgumentParser to make it easier to implement
parseFuture(CommandContext, CommandInput).-
Nested Class Summary
Nested classes/interfaces inherited from interface org.incendo.cloud.parser.ArgumentParser
ArgumentParser.FutureArgumentParser<C,T> -
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull ArgumentParseResult<@NonNull T> parse(@NonNull CommandContext<@NonNull C> commandContext, @NonNull CommandInput commandInput) Attempts to parse theinputinto an object of typeArgumentParser.parseFuture(@NonNull CommandContext<C> commandContext, @NonNull CommandInput commandInput) Returns a future that completes with the result of parsing the givencommandInput.Methods inherited from interface org.incendo.cloud.parser.ArgumentParser
flatMap, flatMapSuccess, mapSuccess, suggestionProvider
-
Method Details
-
parse
default @NonNull ArgumentParseResult<@NonNull T> parse(@NonNull CommandContext<@NonNull C> commandContext, @NonNull CommandInput commandInput) Description copied from interface:ArgumentParserAttempts to parse theinputinto an object of typeArgumentParser.This method may be called when a command chain is being parsed for execution (using
CommandExecutor.executeCommand(Object, String)) or when a command is being parsed to provide context for suggestions (usingSuggestionFactory.suggest(Object, String)). It is possible to useCommandContext.isSuggestions()} to see what the purpose of the parsing is. Particular care should be taken when parsing for suggestions, as the parsing method is then likely to be called once for every character written by the command sender.This method should never throw any exceptions under normal circumstances. Instead, if the parsing for some reason cannot be done successfully
ArgumentParseResult.failure(Throwable)should be returned. This then wraps any exception that should be forwarded to the command sender.The parser is assumed to be completely stateless and should not store any information about the command sender or the command context. Instead, information should be stored in the
CommandContext.- Specified by:
parsein interfaceArgumentParser<C,T> - Parameters:
commandContext- Command contextcommandInput- Command Input- Returns:
- Parsed command result
-
parseFuture
@NonNull CompletableFuture<@NonNull ArgumentParseResult<T>> parseFuture(@NonNull CommandContext<C> commandContext, @NonNull CommandInput commandInput) Description copied from interface:ArgumentParserReturns a future that completes with the result of parsing the givencommandInput.This method may be called when a command chain is being parsed for execution (using
CommandExecutor.executeCommand(Object, String)) or when a command is being parsed to provide context for suggestions (usingSuggestionFactory.suggest(Object, String)). It is possible to useCommandContext.isSuggestions()} to see what the purpose of the parsing is. Particular care should be taken when parsing for suggestions, as the parsing method is then likely to be called once for every character written by the command sender.This method should never throw any exceptions under normal circumstances. Instead, if the parsing for some reason cannot be done successfully
ArgumentParseResult.failure(Throwable)orArgumentParseResult.failureFuture(Throwable)should be returned. This then wraps any exception that should be forwarded to the command sender.The parser is assumed to be completely stateless and should not store any information about the command sender or the command context. Instead, information should be stored in the
CommandContext.- Specified by:
parseFuturein interfaceArgumentParser<C,T> - Parameters:
commandContext- Command contextcommandInput- Command Input- Returns:
- future that completes with the result.
-