Class TranslationOptions
java.lang.Object
com.lokalized.TranslationOptions
Per-invocation options for localized string lookup.
These options override the defaults configured on a Strings instance for a single lookup.
Instances are structurally immutable and safe to share. A configured TranslationFailureHandler or
TranslationFallbackPolicy may be invoked concurrently when the same options are used by concurrent
lookups; application-supplied implementations must therefore be thread-safe.
- Since:
- 3.0.0
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder used to constructTranslationOptionsinstances. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a translation options builder.booleanChecks if this object is equal to another one.static @NonNull TranslationOptionsforLanguageRanges(@NonNull List<@NonNull Locale.LanguageRange> languageRanges) Gets options which use the specified language ranges for a single lookup.static @NonNull TranslationOptionsGets options which use the specified locale for a single lookup.Gets the bidirectional isolation override, if configured.Gets the language-range override, if configured.Gets the locale override, if configured.Gets the translation failure handler override, if configured.Gets the locale-fallback policy override, if configured.inthashCode()A hash code for this object.static @NonNull TranslationOptionsnone()Gets options which do not override anyStringsinstance defaults.Creates a builder initialized with this instance's values.toString()Generates aStringrepresentation of this object.
-
Method Details
-
none
Gets options which do not override anyStringsinstance defaults.- Returns:
- empty translation options, not null
-
forLocale
Gets options which use the specified locale for a single lookup.- Parameters:
locale- locale to use, not null- Returns:
- translation options, not null
- Throws:
IllegalArgumentException- if the locale is not well-formed
-
forLanguageRanges
public static @NonNull TranslationOptions forLanguageRanges(@NonNull List<@NonNull Locale.LanguageRange> languageRanges) Gets options which use the specified language ranges for a single lookup.- Parameters:
languageRanges- language ranges to use, not null- Returns:
- translation options, not null
- Throws:
IllegalArgumentException- if more thanLocaleMatcher.MAXIMUM_LANGUAGE_RANGESlanguage ranges are supplied
-
builder
Creates a translation options builder.- Returns:
- the builder, not null
-
getLocale
-
getLanguageRanges
Gets the language-range override, if configured.- Returns:
- an optional containing the language-range override when configured, otherwise empty. not null
-
getBidiIsolation
Gets the bidirectional isolation override, if configured.- Returns:
- an optional containing the bidirectional isolation override when configured, otherwise empty. not null
-
getTranslationFailureHandler
Gets the translation failure handler override, if configured.The handler may be invoked concurrently when these options are shared and must be thread-safe.
- Returns:
- an optional containing the translation failure handler override when configured, otherwise empty. not null
-
getTranslationFallbackPolicy
Gets the locale-fallback policy override, if configured.The policy may be invoked concurrently when these options are shared and must be thread-safe.
- Returns:
- configured fallback policy, or empty, not null
-
toBuilder
Creates a builder initialized with this instance's values.- Returns:
- the builder, not null
-
toString
-
equals
-
hashCode
-