Interface ResolverRegistrar<S extends Source>

Type Parameters:
S - the type of source that this registrar handles
All Known Subinterfaces:
ImperatConfig<S>

public sealed interface ResolverRegistrar<S extends Source> permits ImperatConfig<S>
The ResolverRegistrar interface provides mechanisms for registering and retrieving various types of resolvers, factories, and initializers that are contextually linked to specific source types and value types. It is a sealed interface, which limits its implementation to specific permitted types.
  • Method Details

    • registerContextResolverFactory

      <T> void registerContextResolverFactory(Type type, ContextResolverFactory<S,T> factory)
      Registers a context resolver factory
      Parameters:
      factory - the factory to register
    • registerContextResolver

      <T> void registerContextResolver(Type type, @NotNull @NotNull ContextResolver<S,T> resolver)
      Registers ContextResolver
      Type Parameters:
      T - the valueType of value being resolved from context
      Parameters:
      type - the class-valueType of value being resolved from context
      resolver - the resolver for this value
    • registerParamType

      <T> void registerParamType(Type type, @NotNull @NotNull ParameterType<S,T> resolver)
      Registers ParameterType
      Type Parameters:
      T - the valueType of value being resolved from context
      Parameters:
      type - the class-valueType of value being resolved from context
      resolver - the resolver for this value
    • registerCollectionInitializer

      <C extends Collection<?>> void registerCollectionInitializer(Class<C> collectionType, Supplier<C> newInstanceSupplier)
      Registers a supplier function that provides new instances of a specific Collection type. This allows the framework to create appropriate collection instances during deserialization or initialization processes.
      Type Parameters:
      C - the type of Collection to be initialized
      Parameters:
      collectionType - the Class object representing the collection type
      newInstanceSupplier - a Supplier that creates new instances of the collection type
      Throws:
      NullPointerException - if collectionType or newInstanceSupplier is null
    • registerMapInitializer

      <M extends Map<?, ?>> void registerMapInitializer(Class<M> mapType, Supplier<M> newInstanceSupplier)
      Registers a supplier function that provides new instances of a specific Map type. This allows the framework to create appropriate map instances during deserialization or initialization processes.
      Type Parameters:
      M - the type of Map to be initialized
      Parameters:
      mapType - the Class object representing the map type
      newInstanceSupplier - a Supplier that creates new instances of the map type
      Throws:
      NullPointerException - if mapType or newInstanceSupplier is null
    • getDefaultSuggestionResolver

      SuggestionResolver<S> getDefaultSuggestionResolver()
      Retrieves the default suggestion resolver associated with this registrar.
      Returns:
      the SuggestionResolver instance used as the default resolver
    • setDefaultSuggestionResolver

      void setDefaultSuggestionResolver(SuggestionResolver<S> defaultSuggestionResolver)
      Sets the default suggestion resolver to be used when no specific suggestion resolver is provided. The default suggestion resolver handles the auto-completion of arguments/parameters for commands.
      Parameters:
      defaultSuggestionResolver - the SuggestionResolver to be set as default
    • getParameterSuggestionResolver

      @NotNull default @NotNull SuggestionResolver<S> getParameterSuggestionResolver(CommandParameter<S> parameter)
      Fetches the suggestion provider/resolver for a specific valueType of argument or parameter.
      Parameters:
      parameter - the parameter symbolizing the valueType and argument name
      Returns:
      the SuggestionResolver instance for that valueType
    • getSuggestionResolverByType

      @Nullable @Nullable SuggestionResolver<S> getSuggestionResolverByType(Type type)
      Fetches the suggestion provider/resolver for a specific valueType of argument or parameter.
      Parameters:
      type - the valueType
      Returns:
      the SuggestionResolver instance for that valueType
    • getNamedSuggestionResolver

      @Nullable @Nullable SuggestionResolver<S> getNamedSuggestionResolver(String name)
      Fetches the suggestion provider/resolver registered by its unique name
      Parameters:
      name - the name of the argument
      Returns:
      the SuggestionResolver instance for that argument
    • registerNamedSuggestionResolver

      void registerNamedSuggestionResolver(String name, SuggestionResolver<S> suggestionResolver)
      Registers a suggestion resolver
      Parameters:
      name - the name of the suggestion resolver
      suggestionResolver - the suggestion resolver to register
    • getSourceResolver

      @Nullable <R> @Nullable SourceResolver<S,R> getSourceResolver(Type type)
      Fetches the SourceResolver from an internal registry.
      Type Parameters:
      R - the new source valueType parameter
      Parameters:
      type - the target source valueType
      Returns:
      the SourceResolver for specific valueType
    • registerSourceResolver

      default <R> void registerSourceResolver(TypeWrap<R> type, SourceResolver<S,R> sourceResolver)
      Registers the SourceResolver into an internal registry
      Type Parameters:
      R - the new source valueType parameter
      Parameters:
      type - the target source valueType
      sourceResolver - the source resolver to register
    • registerSourceResolver

      <R> void registerSourceResolver(Type type, SourceResolver<S,R> sourceResolver)
      Registers the SourceResolver into an internal registry
      Type Parameters:
      R - the new source valueType parameter
      Parameters:
      type - the target source valueType
      sourceResolver - the source resolver to register
    • getReturnResolver

      @Nullable <T> @Nullable ReturnResolver<S,T> getReturnResolver(Type type)
      Fetches the ReturnResolver from an internal registry.
      Parameters:
      type - the target type
      Returns:
      the ReturnResolver for specific type
    • registerReturnResolver

      default <T> void registerReturnResolver(TypeWrap<T> type, ReturnResolver<S,T> returnResolver)
      Registers the ReturnResolver into an internal registry
      Parameters:
      type - the target type
      returnResolver - the return resolver to register
    • registerReturnResolver

      <T> void registerReturnResolver(Type type, ReturnResolver<S,T> returnResolver)
      Registers the ReturnResolver into an internal registry
      Parameters:
      type - the target type
      returnResolver - the return resolver to register
    • registerPlaceholder

      void registerPlaceholder(Placeholder<S> placeholder)
      Registers a placeholder
      Parameters:
      placeholder - to register