Interface ParserRegistry<C>
-
- Type Parameters:
C
- Command sender type
- All Known Implementing Classes:
StandardParserRegistry
public interface ParserRegistry<C>
Registry ofArgumentParser
that allows these arguments to be referenced by aClass
(or really, aTypeToken
) or aString
key
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> @NonNull java.util.Optional<ArgumentParser<C,T>>
createParser(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull ParserParameters parserParameters)
Attempt to create aArgumentParser
for a specified type, using an instance ofParserParameter
to configure the parser settings<T> @NonNull java.util.Optional<ArgumentParser<C,T>>
createParser(@NonNull java.lang.String name, @NonNull ParserParameters parserParameters)
Attempt to create aArgumentParser
for a specified type, using an instance ofParserParameter
to configure the parser settings@NonNull java.util.Optional<java.util.function.BiFunction<@NonNull CommandContext<C>,@NonNull java.lang.String,@NonNull java.util.List<java.lang.String>>>
getSuggestionProvider(@NonNull java.lang.String name)
Get a named suggestion provider, if a suggestion provider with the given name exists in the registry@NonNull ParserParameters
parseAnnotations(@NonNull io.leangen.geantyref.TypeToken<?> parsingType, @NonNull java.util.Collection<? extends java.lang.annotation.Annotation> annotations)
Parse annotations intoParserParameters
<A extends java.lang.annotation.Annotation,T>
voidregisterAnnotationMapper(@NonNull java.lang.Class<A> annotation, @NonNull java.util.function.BiFunction<@NonNull A,@NonNull io.leangen.geantyref.TypeToken<?>,@NonNull ParserParameters> mapper)
Register a mapper that maps annotation instances to a map of parameter-object pairsvoid
registerNamedParserSupplier(@NonNull java.lang.String name, @NonNull java.util.function.Function<@NonNull ParserParameters,@NonNull ArgumentParser<C,?>> supplier)
Register a named parser supplier<T> void
registerParserSupplier(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull java.util.function.Function<@NonNull ParserParameters,@NonNull ArgumentParser<C,?>> supplier)
Register a parser suppliervoid
registerSuggestionProvider(@NonNull java.lang.String name, @NonNull java.util.function.BiFunction<@NonNull CommandContext<C>,@NonNull java.lang.String,@NonNull java.util.List<java.lang.String>> suggestionsProvider)
Register a new named suggestion provider
-
-
-
Method Detail
-
registerParserSupplier
<T> void registerParserSupplier(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull java.util.function.Function<@NonNull ParserParameters,@NonNull ArgumentParser<C,?>> supplier)
Register a parser supplier- 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
void registerNamedParserSupplier(@NonNull java.lang.String name, @NonNull java.util.function.Function<@NonNull ParserParameters,@NonNull ArgumentParser<C,?>> supplier)
Register a named parser supplier- 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
<A extends java.lang.annotation.Annotation,T> void registerAnnotationMapper(@NonNull java.lang.Class<A> annotation, @NonNull java.util.function.BiFunction<@NonNull A,@NonNull io.leangen.geantyref.TypeToken<?>,@NonNull ParserParameters> mapper)
Register a mapper that maps annotation instances to a map of parameter-object pairs- 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
-object
pairs
-
parseAnnotations
@NonNull ParserParameters parseAnnotations(@NonNull io.leangen.geantyref.TypeToken<?> parsingType, @NonNull java.util.Collection<? extends java.lang.annotation.Annotation> annotations)
Parse annotations intoParserParameters
- 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
<T> @NonNull java.util.Optional<ArgumentParser<C,T>> createParser(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull ParserParameters parserParameters)
Attempt to create aArgumentParser
for a specified type, using an instance ofParserParameter
to configure the parser settings- 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
<T> @NonNull java.util.Optional<ArgumentParser<C,T>> createParser(@NonNull java.lang.String name, @NonNull ParserParameters parserParameters)
Attempt to create aArgumentParser
for a specified type, using an instance ofParserParameter
to configure the parser settings- Type Parameters:
T
- Generic type- Parameters:
name
- ParserparserParameters
- Parser parameters- Returns:
- Parser, if one can be created
-
registerSuggestionProvider
void registerSuggestionProvider(@NonNull java.lang.String name, @NonNull java.util.function.BiFunction<@NonNull CommandContext<C>,@NonNull java.lang.String,@NonNull java.util.List<java.lang.String>> suggestionsProvider)
Register a new named suggestion provider- Parameters:
name
- Name of the suggestions provider. The name is case independent.suggestionsProvider
- The suggestions provider- Since:
- 1.1.0
- See Also:
Get a suggestion provider
-
getSuggestionProvider
@NonNull java.util.Optional<java.util.function.BiFunction<@NonNull CommandContext<C>,@NonNull java.lang.String,@NonNull java.util.List<java.lang.String>>> getSuggestionProvider(@NonNull java.lang.String name)
Get a named suggestion provider, if a suggestion provider with the given name exists in the registry- 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
- Since:
- 1.1.0
- See Also:
Register a suggestion provider
-
-