Package org.nuclos.api.l10n
Interface TranslatorFactory<T extends Translator>
- Type Parameters:
T- The specific type ofTranslatorthat 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 TypeMethodDescriptiondefault booleanautoSetup(Locale sourceLocale, Locale targetLocale, javax.json.JsonObjectBuilder configBuilder, javax.json.JsonObject translatorBaseConfig) Attempts to perform an automatic setup for the givenlocales.javax.json.JsonObjectGets the default configuration for this translator as a JSON object.getName()Gets the name of this translator factory.Gets the class object for the translator type created by this factory.getUrl()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
Gets the class object for the translator type created by this factory.- Returns:
- The class object representing the translator type
-
newInstance
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 givenlocales.If
trueis returned, theconfigBuilderhas been filled with valid auto-setup values for the specified locale. Iffalse, no auto-setup was performed and theconfigBuilderremains unchanged.The optional
translatorBaseConfigmay provide default values or fallbacks to use during the auto-setup.- Parameters:
sourceLocale- the sourceLocalefor which to attempt auto-setup; must not benulltargetLocale- the targetLocalefor which to attempt auto-setup; must not benullconfigBuilder- theJsonObjectBuilderinto which auto-setup configuration entries will be written; must not benulltranslatorBaseConfig- an optionalJsonObjectcontaining base or fallback values for the auto-setup; may benull- Returns:
trueif auto-setup was applied andconfigBuilderwas populated;falseif no auto-setup was performed
-