Class MappedArgumentParserImpl<C,I,O>
- All Implemented Interfaces:
ArgumentParser<C,,O> ArgumentParser.FutureArgumentParser<C,,O> MappedArgumentParser<C,,I, O> SuggestionProviderHolder<C>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.incendo.cloud.parser.ArgumentParser
ArgumentParser.FutureArgumentParser<C,T> Nested classes/interfaces inherited from interface org.incendo.cloud.parser.MappedArgumentParser
MappedArgumentParser.Mapper<C,I, O> -
Method Summary
Modifier and TypeMethodDescriptionGet the parser this one is derived from.boolean<O1> @NonNull ArgumentParser.FutureArgumentParser<C, O1> flatMap(MappedArgumentParser.Mapper<C, O, O1> mapper) Create a derived argument parser preserving all properties of this parser, but converting the output type.inthashCode()parseFuture(@NonNull CommandContext<@NonNull C> commandContext, @NonNull CommandInput commandInput) Returns a future that completes with the result of parsing the givencommandInput.Returns the suggestion provider.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.incendo.cloud.parser.ArgumentParser
flatMapSuccess, mapSuccessMethods inherited from interface org.incendo.cloud.parser.ArgumentParser.FutureArgumentParser
parse
-
Method Details
-
baseParser
Description copied from interface:MappedArgumentParserGet the parser this one is derived from.- Specified by:
baseParserin interfaceMappedArgumentParser<C,I, O> - Returns:
- the base parser
-
parseFuture
public @NonNull CompletableFuture<@NonNull ArgumentParseResult<O>> parseFuture(@NonNull CommandContext<@NonNull 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,I> - Specified by:
parseFuturein interfaceArgumentParser.FutureArgumentParser<C,I> - Parameters:
commandContext- Command contextcommandInput- Command Input- Returns:
- future that completes with the result.
-
suggestionProvider
Description copied from interface:ArgumentParserReturns the suggestion provider.By default, this will return the parser, if the parser is also a
SuggestionProvider. Otherwise,SuggestionProvider.noSuggestions()will be returned.- Specified by:
suggestionProviderin interfaceArgumentParser<C,I> - Specified by:
suggestionProviderin interfaceSuggestionProviderHolder<C>- Returns:
- the suggestion provider
-
flatMap
public <O1> @NonNull ArgumentParser.FutureArgumentParser<C,O1> flatMap(MappedArgumentParser.Mapper<C, O, O1> mapper) Description copied from interface:ArgumentParserCreate a derived argument parser preserving all properties of this parser, but converting the output type.- Specified by:
flatMapin interfaceArgumentParser<C,I> - Type Parameters:
O1- the result type- Parameters:
mapper- the mapper to apply- Returns:
- a derived parser.
-
hashCode
public int hashCode() -
equals
-
toString
-