Interface TranslatorFactory<T extends Translator>

Type Parameters:
T - The specific type of Translator that this factory creates

public interface TranslatorFactory<T extends Translator>
Factory interface for creating Translator instances.

This interface defines methods for creating, configuring and identifying translator implementations. It allows to instantiate specific translator types with appropriate configuration.

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    autoSetup(Locale sourceLocale, Locale targetLocale, javax.json.JsonObjectBuilder configBuilder, javax.json.JsonObject translatorBaseConfig)
    Attempts to perform an automatic setup for the given locales.
    javax.json.JsonObject
    Gets the default configuration for this translator as a JSON object.
    Gets the name of this translator factory.
    Gets the class object for the translator type created by this factory.
    Gets the URL associated with this translator factory.
    newInstance(javax.json.JsonObject jsonConfig)
    Creates a new instance of the translator with the specified JSON configuration.
  • Method Details

    • getName

      String getName()
      Gets the name of this translator factory.
      Returns:
      The unique name that identifies this translator implementation
    • getUrl

      URL getUrl()
      Gets the URL associated with this translator factory. This might be a documentation link.
      Returns:
      The URL associated with this translator factory
    • getDefaultConfigJson

      javax.json.JsonObject getDefaultConfigJson()
      Gets the default configuration for this translator as a JSON object.
      Returns:
      The default configuration as a JSON object
    • getTranslatorClass

      Class<T> getTranslatorClass()
      Gets the class object for the translator type created by this factory.
      Returns:
      The class object representing the translator type
    • newInstance

      T newInstance(javax.json.JsonObject jsonConfig) throws Exception
      Creates a new instance of the translator with the specified JSON configuration.
      Parameters:
      jsonConfig - The JSON configuration to use when creating the translator instance
      Returns:
      A new translator instance
      Throws:
      Exception - If an error occurs while creating the translator instance
    • autoSetup

      default boolean autoSetup(@NotNull Locale sourceLocale, @NotNull Locale targetLocale, @NotNull javax.json.JsonObjectBuilder configBuilder, @NotNull javax.json.JsonObject translatorBaseConfig)
      Attempts to perform an automatic setup for the given locales.

      If true is returned, the configBuilder has been filled with valid auto-setup values for the specified locale. If false, no auto-setup was performed and the configBuilder remains unchanged.

      The optional translatorBaseConfig may provide default values or fallbacks to use during the auto-setup.

      Parameters:
      sourceLocale - the source Locale for which to attempt auto-setup; must not be null
      targetLocale - the target Locale for which to attempt auto-setup; must not be null
      configBuilder - the JsonObjectBuilder into which auto-setup configuration entries will be written; must not be null
      translatorBaseConfig - an optional JsonObject containing base or fallback values for the auto-setup; may be null
      Returns:
      true if auto-setup was applied and configBuilder was populated; false if no auto-setup was performed