Package org.nuclos.api.l10n
Interface TranslatorFactory<T extends Translator>
- Type Parameters:
T
- The specific type ofTranslator
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 TypeMethodDescriptiondefault boolean
autoSetup
(Locale sourceLocale, Locale targetLocale, javax.json.JsonObjectBuilder configBuilder, javax.json.JsonObject translatorBaseConfig) Attempts to perform an automatic setup for the givenlocale
s.javax.json.JsonObject
Gets 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 givenlocale
s.If
true
is returned, theconfigBuilder
has been filled with valid auto-setup values for the specified locale. Iffalse
, no auto-setup was performed and theconfigBuilder
remains unchanged.The optional
translatorBaseConfig
may provide default values or fallbacks to use during the auto-setup.- Parameters:
sourceLocale
- the sourceLocale
for which to attempt auto-setup; must not benull
targetLocale
- the targetLocale
for which to attempt auto-setup; must not benull
configBuilder
- theJsonObjectBuilder
into which auto-setup configuration entries will be written; must not benull
translatorBaseConfig
- an optionalJsonObject
containing base or fallback values for the auto-setup; may benull
- Returns:
true
if auto-setup was applied andconfigBuilder
was populated;false
if no auto-setup was performed
-