Class AIServiceCollection


  • public class AIServiceCollection
    extends Object
    A collection that can hold AI services
    • Constructor Detail

      • AIServiceCollection

        public AIServiceCollection()
    • Method Detail

      • setService

        public <T extends AIService> void setService​(T service,
                                                     Class<T> serviceType)
        Registers a singleton service instance with the default name.
        Parameters:
        service - The service instance.
        serviceType - The type of the service.
      • setService

        public <T extends AIService> void setService​(String name,
                                                     T service,
                                                     boolean setAsDefault,
                                                     Class<T> serviceType)
        Registers a singleton service instance with an optional name and default flag.
        Parameters:
        name - The name of the service, or null for the default service.
        service - The service instance.
        setAsDefault - Whether the service should be the default for its type.
        serviceType - The type of the service.
      • setService

        public <T extends AIService> void setService​(Supplier<T> factory,
                                                     Class<T> serviceType)
        Registers a transient service factory with the default name.
        Parameters:
        factory - The factory function to create the service instance.
        serviceType - The type of the service.
      • setService

        public <T extends AIService> void setService​(@Nullable
                                                     String name,
                                                     Supplier<T> factory,
                                                     boolean setAsDefault,
                                                     Class<T> serviceType)
        Registers a transient service factory with an optional name and default flag.
        Parameters:
        name - The name of the service, or null for the default service.
        factory - The factory function to create the service instance.
        setAsDefault - Whether the service should be the default for its type.
        serviceType - The type of the service.
      • build

        public AIServiceProvider build()
        Builds an AIServiceProvider from the registered services and default names.
        Returns:
        The AIServiceProvider.