Class TranslationOptions.Builder
java.lang.Object
com.lokalized.TranslationOptions.Builder
- Enclosing class:
TranslationOptions
Builder used to construct
TranslationOptions instances.
This class is intended for use by a single thread.
Locale and language-range overrides are mutually exclusive. If both setters are used, the last non-null setter wins and clears the earlier override.
- Since:
- 3.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionbidiIsolation(@Nullable BidiIsolation bidiIsolation) Applies a bidirectional isolation override.build()Constructs aTranslationOptionsinstance.languageRanges(@Nullable List<@NonNull Locale.LanguageRange> languageRanges) Applies a language-range override.Applies a locale override.translationFailureHandler(@Nullable TranslationFailureHandler translationFailureHandler) Applies a translation failure handler override.translationFallbackPolicy(@Nullable TranslationFallbackPolicy translationFallbackPolicy) Applies a locale-fallback policy override for this lookup.
-
Method Details
-
locale
Applies a locale override.Supplying a non-null locale clears any language-range override.
- Parameters:
locale- locale to use, may be null- Returns:
- this builder, not null
- Throws:
IllegalArgumentException- if the locale is not well-formed
-
languageRanges
public @NonNull TranslationOptions.Builder languageRanges(@Nullable List<@NonNull Locale.LanguageRange> languageRanges) Applies a language-range override.Supplying non-null language ranges clears any locale override.
- Parameters:
languageRanges- language ranges to use, may be null- Returns:
- this builder, not null
- Throws:
IllegalArgumentException- if more thanLocaleMatcher.MAXIMUM_LANGUAGE_RANGESlanguage ranges are supplied
-
bidiIsolation
Applies a bidirectional isolation override.- Parameters:
bidiIsolation- bidirectional isolation behavior, may be null- Returns:
- this builder, not null
-
translationFailureHandler
public @NonNull TranslationOptions.Builder translationFailureHandler(@Nullable TranslationFailureHandler translationFailureHandler) Applies a translation failure handler override.The handler may be invoked concurrently after the options are built and must be thread-safe.
- Parameters:
translationFailureHandler- handler for failed lookups, may be null- Returns:
- this builder, not null
-
translationFallbackPolicy
public @NonNull TranslationOptions.Builder translationFallbackPolicy(@Nullable TranslationFallbackPolicy translationFallbackPolicy) Applies a locale-fallback policy override for this lookup.The policy may be invoked concurrently after the options are built and must be thread-safe.
- Parameters:
translationFallbackPolicy- locale-fallback policy, may be null- Returns:
- this builder, not null
-
build
Constructs aTranslationOptionsinstance.- Returns:
- translation options, not null
-