Package com.lokalized
Class DefaultStrings.Builder
java.lang.Object
com.lokalized.DefaultStrings.Builder
- Enclosing class:
DefaultStrings
Builder used to construct instances of
DefaultStrings
.
You cannot provide both a localeSupplier
and a languageRangesSupplier
- you must choose one or neither.
This class is intended for use by a single thread.
- Author:
- Mark Allen
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Constructs an instance ofDefaultStrings
.failureMode
(DefaultStrings.FailureMode failureMode) Applies a failure mode to this builder.languageRangesSupplier
(Supplier<List<Locale.LanguageRange>> languageRangesSupplier) Applies a supplier of language ranges to this builder.localeSupplier
(Supplier<Locale> localeSupplier) Applies a locale supplier to this builder.
-
Constructor Details
-
Builder
public Builder(@Nonnull String fallbackLanguageCode, @Nonnull Supplier<Map<Locale, ? extends Iterable<LocalizedString>>> localizedStringSupplier) Constructs a strings builder with a default language code and localized string supplier.The fallback language code must be an ISO 639 alpha-2 or alpha-3 language code. When a language has both an alpha-2 code and an alpha-3 code, the alpha-2 code must be used.
- Parameters:
fallbackLanguageCode
- fallback language code, not nulllocalizedStringSupplier
- supplier of localized strings, not null
-
-
Method Details
-
localeSupplier
Applies a locale supplier to this builder.- Parameters:
localeSupplier
- locale supplier, may be null- Returns:
- this builder instance, useful for chaining. not null
-
languageRangesSupplier
@Nonnull public DefaultStrings.Builder languageRangesSupplier(@Nullable Supplier<List<Locale.LanguageRange>> languageRangesSupplier) Applies a supplier of language ranges to this builder.- Parameters:
languageRangesSupplier
- language ranges supplier, may be null- Returns:
- this builder instance, useful for chaining. not null
-
failureMode
@Nonnull public DefaultStrings.Builder failureMode(@Nullable DefaultStrings.FailureMode failureMode) Applies a failure mode to this builder.- Parameters:
failureMode
- strategy for dealing with lookup failures, may be null- Returns:
- this builder instance, useful for chaining. not null
-
build
Constructs an instance ofDefaultStrings
.- Returns:
- an instance of
DefaultStrings
, not null
-