Class LocaleMatchResult
java.lang.Object
com.lokalized.LocaleMatchResult
- All Implemented Interfaces:
Serializable
Strict, immutable diagnostic result for locale negotiation.
This value supports Java serialization, including its requested Locale.LanguageRange values.
- Since:
- 3.0.0
- Author:
- Mark Allen
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLocaleMatchResult(@NonNull List<@NonNull Locale.LanguageRange> requestedLanguageRanges, @Nullable Locale locale, @Nullable Locale.LanguageRange languageRange, @Nullable Double effectiveWeight, @NonNull LocaleMatchType matchType, @NonNull Locale fallbackLocale, @NonNull List<@NonNull Locale> consideredLocales) Constructs a locale match result. -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the ordered supported locales considered by negotiation.Gets the selected locale's effective preference weight after specific-range overrides.Gets the configured fallback thatLocaleMatcher.bestMatchFor(List)would use for no match.Gets the preference range associated with the selection.Gets the selected supported locale.Gets the relationship used for the selection.Gets the language ranges supplied for negotiation in caller order.inthashCode()isMatch()Reports whether negotiation selected an acceptable supported locale.toString()
-
Constructor Details
-
LocaleMatchResult
public LocaleMatchResult(@NonNull List<@NonNull Locale.LanguageRange> requestedLanguageRanges, @Nullable Locale locale, @Nullable Locale.LanguageRange languageRange, @Nullable Double effectiveWeight, @NonNull LocaleMatchType matchType, @NonNull Locale fallbackLocale, @NonNull List<@NonNull Locale> consideredLocales) Constructs a locale match result. This is public so customLocaleMatcherimplementations can expose the same diagnostics.- Parameters:
requestedLanguageRanges- ranges supplied for negotiation, not nulllocale- selected supported locale, or null for no matchlanguageRange- range associated with the selection, or null for no matcheffectiveWeight- selected locale's effective quality, or null for no matchmatchType- match relationship, not nullfallbackLocale- configured fallback locale, not nullconsideredLocales- supported locales considered, not null- Throws:
IllegalArgumentException- if more thanLocaleMatcher.MAXIMUM_LANGUAGE_RANGESrequested language ranges are supplied, any locale is malformed, considered locales have duplicate language tags, matched and unmatched state is mixed, the effective weight is outside(0, 1], or selected/fallback locales were not considered
-
-
Method Details
-
getRequestedLanguageRanges
Gets the language ranges supplied for negotiation in caller order.- Returns:
- language ranges supplied for negotiation in caller order, not null
-
getLocale
-
getLanguageRange
Gets the preference range associated with the selection.- Returns:
- preference range associated with the selection, or empty for no match, not null
-
getEffectiveWeight
Gets the selected locale's effective preference weight after specific-range overrides.- Returns:
- selected locale's effective preference weight after specific-range overrides, or empty for no match, not null
-
getMatchType
Gets the relationship used for the selection.- Returns:
- relationship used for the selection, or
LocaleMatchType.NONE, not null
-
getFallbackLocale
Gets the configured fallback thatLocaleMatcher.bestMatchFor(List)would use for no match.- Returns:
- configured fallback that
LocaleMatcher.bestMatchFor(List)would use for no match, not null
-
getConsideredLocales
Gets the ordered supported locales considered by negotiation.- Returns:
- ordered supported locales considered by negotiation, not null
-
isMatch
-
equals
-
hashCode
-
toString
-