Interface ParserRegistry<C>

Type Parameters:
C - Command sender type
All Known Implementing Classes:
StandardParserRegistry

@API(status=STABLE) public interface ParserRegistry<C>
Registry of ArgumentParser that allows these arguments to be referenced by a Class (or really, a TypeToken) or a String key
  • Method Details

    • registerParserSupplier

      <T> void registerParserSupplier(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull 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 parser
      supplier - The function that generates the parser. The map supplied my contain parameters used to configure the parser, many of which are documented in StandardParameters
    • registerNamedParserSupplier

      void registerNamedParserSupplier(@NonNull String name, @NonNull Function<@NonNull ParserParameters,@NonNull ArgumentParser<C,?>> supplier)
      Register a named parser supplier
      Parameters:
      name - Parser name
      supplier - The function that generates the parser. The map supplied my contain parameters used to configure the parser, many of which are documented in StandardParameters
    • registerAnnotationMapper

      <A extends Annotation, T> void registerAnnotationMapper(@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 pairs
      Type Parameters:
      A - Annotation type
      T - Type of the object that the parser is retrieved for
      Parameters:
      annotation - Annotation class
      mapper - Mapper that maps the pair (annotation, type to be parsed) to a map of parameter-object pairs
    • parseAnnotations

      @NonNull ParserParameters parseAnnotations(@NonNull io.leangen.geantyref.TypeToken<?> parsingType, @NonNull Collection<? extends Annotation> annotations)
      Parse annotations into ParserParameters
      Parameters:
      parsingType - The type that is produced by the parser that is requesting the parsing parameters
      annotations - The annotations to be parsed
      Returns:
      Parsed parameters
    • createParser

      <T> @NonNull Optional<ArgumentParser<C,T>> createParser(@NonNull io.leangen.geantyref.TypeToken<T> type, @NonNull ParserParameters parserParameters)
      Attempt to create a ArgumentParser for a specified type, using an instance of ParserParameter to configure the parser settings
      Type Parameters:
      T - Generic type
      Parameters:
      type - Type that should be produced by the parser
      parserParameters - Parser parameters
      Returns:
      Parser, if one can be created
    • createParser

      <T> @NonNull Optional<ArgumentParser<C,T>> createParser(@NonNull String name, @NonNull ParserParameters parserParameters)
      Attempt to create a ArgumentParser for a specified type, using an instance of ParserParameter to configure the parser settings
      Type Parameters:
      T - Generic type
      Parameters:
      name - Parser
      parserParameters - Parser parameters
      Returns:
      Parser, if one can be created
    • registerSuggestionProvider

      @API(status=STABLE, since="1.1.0") void registerSuggestionProvider(@NonNull String name, @NonNull BiFunction<@NonNull CommandContext<C>,@NonNull String,@NonNull List<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:
    • getSuggestionProvider

      @API(status=STABLE, since="1.1.0") @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
      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: