Class StandardParserRegistry<C>
java.lang.Object
cloud.commandframework.arguments.parser.StandardParserRegistry<C>
- Type Parameters:
C- Command sender type
- All Implemented Interfaces:
ParserRegistry<C>
@API(status=STABLE)
public final class StandardParserRegistry<C>
extends Object
implements ParserRegistry<C>
Standard implementation of
ParserRegistry-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> @NonNull Optional<ArgumentParser<C,T>> createParser(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull ParserParameters parserParameters) Attempt to create aArgumentParserfor a specified type, using an instance ofParserParameterto configure the parser settings<T> @NonNull Optional<ArgumentParser<C,T>> createParser(@NonNull String name, @NonNull ParserParameters parserParameters) Attempt to create aArgumentParserfor a specified type, using an instance ofParserParameterto configure the parser settings@NonNull Optional<BiFunction<@NonNull CommandContext<C>,@NonNull String, @NonNull List<String>>> getSuggestionProvider(@NonNull String name) Get a named suggestion provider, if a suggestion provider with the given name exists in the registry@NonNull ParserParametersparseAnnotations(@NonNull io.leangen.geantyref.TypeToken<?> parsingType, @NonNull Collection<@NonNull ? extends Annotation> annotations) Parse annotations intoParserParameters<A extends Annotation,T>
voidregisterAnnotationMapper(@NonNull Class<A> annotation, @NonNull BiFunction<@NonNull A, @NonNull io.leangen.geantyref.TypeToken<?>, @NonNull ParserParameters> mapper) Register a mapper that maps annotation instances to a map of parameter-object pairsvoidregisterNamedParserSupplier(@NonNull String name, @NonNull Function<@NonNull ParserParameters, @NonNull ArgumentParser<C, ?>> supplier) Register a named parser supplier<T> voidregisterParserSupplier(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull Function<@NonNull ParserParameters, @NonNull ArgumentParser<C, ?>> supplier) Register a parser suppliervoidregisterSuggestionProvider(@NonNull String name, @NonNull BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>> suggestionsProvider) Register a new named suggestion provider
-
Constructor Details
-
StandardParserRegistry
public StandardParserRegistry()Construct a newStandardParserRegistryinstance. This will also register all standard annotation mappers and parser suppliers
-
-
Method Details
-
registerParserSupplier
public <T> void registerParserSupplier(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull Function<@NonNull ParserParameters, @NonNull ArgumentParser<C, ?>> supplier) Description copied from interface:ParserRegistryRegister a parser supplier- Specified by:
registerParserSupplierin interfaceParserRegistry<C>- Type Parameters:
T- Generic type specifying what is produced by the parser- Parameters:
type- The type that is parsed by the parsersupplier- The function that generates the parser. The map supplied my contain parameters used to configure the parser, many of which are documented inStandardParameters
-
registerNamedParserSupplier
public void registerNamedParserSupplier(@NonNull String name, @NonNull Function<@NonNull ParserParameters, @NonNull ArgumentParser<C, ?>> supplier) Description copied from interface:ParserRegistryRegister a named parser supplier- Specified by:
registerNamedParserSupplierin interfaceParserRegistry<C>- Parameters:
name- Parser namesupplier- The function that generates the parser. The map supplied my contain parameters used to configure the parser, many of which are documented inStandardParameters
-
registerAnnotationMapper
public <A extends Annotation,T> void registerAnnotationMapper(@NonNull Class<A> annotation, @NonNull BiFunction<@NonNull A, @NonNull io.leangen.geantyref.TypeToken<?>, @NonNull ParserParameters> mapper) Description copied from interface:ParserRegistryRegister a mapper that maps annotation instances to a map of parameter-object pairs- Specified by:
registerAnnotationMapperin interfaceParserRegistry<C>- Type Parameters:
A- Annotation typeT- Type of the object that the parser is retrieved for- Parameters:
annotation- Annotation classmapper- Mapper that maps the pair (annotation, type to be parsed) to a map ofparameter-objectpairs
-
parseAnnotations
public @NonNull ParserParameters parseAnnotations(@NonNull io.leangen.geantyref.TypeToken<?> parsingType, @NonNull Collection<@NonNull ? extends Annotation> annotations) Description copied from interface:ParserRegistryParse annotations intoParserParameters- Specified by:
parseAnnotationsin interfaceParserRegistry<C>- Parameters:
parsingType- The type that is produced by the parser that is requesting the parsing parametersannotations- The annotations to be parsed- Returns:
- Parsed parameters
-
createParser
public <T> @NonNull Optional<ArgumentParser<C,T>> createParser(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull ParserParameters parserParameters) Description copied from interface:ParserRegistryAttempt to create aArgumentParserfor a specified type, using an instance ofParserParameterto configure the parser settings- Specified by:
createParserin interfaceParserRegistry<C>- Type Parameters:
T- Generic type- Parameters:
type- Type that should be produced by the parserparserParameters- Parser parameters- Returns:
- Parser, if one can be created
-
createParser
public <T> @NonNull Optional<ArgumentParser<C,T>> createParser(@NonNull String name, @NonNull ParserParameters parserParameters) Description copied from interface:ParserRegistryAttempt to create aArgumentParserfor a specified type, using an instance ofParserParameterto configure the parser settings- Specified by:
createParserin interfaceParserRegistry<C>- Type Parameters:
T- Generic type- Parameters:
name- ParserparserParameters- Parser parameters- Returns:
- Parser, if one can be created
-
registerSuggestionProvider
public void registerSuggestionProvider(@NonNull String name, @NonNull BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<String>> suggestionsProvider) Description copied from interface:ParserRegistryRegister a new named suggestion provider- Specified by:
registerSuggestionProviderin interfaceParserRegistry<C>- Parameters:
name- Name of the suggestions provider. The name is case independent.suggestionsProvider- The suggestions provider- See Also:
-
getSuggestionProvider
public @NonNull Optional<BiFunction<@NonNull CommandContext<C>,@NonNull String, getSuggestionProvider@NonNull List<String>>> (@NonNull String name) Description copied from interface:ParserRegistryGet a named suggestion provider, if a suggestion provider with the given name exists in the registry- Specified by:
getSuggestionProviderin interfaceParserRegistry<C>- Parameters:
name- Suggestion provider name. The name is case independent.- Returns:
- Optional that either contains the suggestion provider, or is empty if no suggestion provider is registered with the given name
- See Also:
-