Class TranslationFallbackEvent
java.lang.Object
com.lokalized.TranslationFallbackEvent
Diagnostic event for a lookup whose later locale candidate supplied a translation.
The event records every preceding candidate's own failure reason and cause, in attempt order. It contains no rendered translation or caller placeholder values. Collection state is unmodifiable; runtime causes are exposed by reference and are outside this class's thread-safety guarantee.
- Since:
- 3.1.1
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFailure of one locale candidate preceding a successful fallback translation. -
Constructor Summary
ConstructorsConstructorDescriptionTranslationFallbackEvent(@NonNull TranslationResult translationResult, @NonNull List<@NonNull TranslationFallbackEvent.PrecedingFailure> precedingFailures) Constructs an event from a successful result and the failures preceding it. -
Method Summary
Modifier and TypeMethodDescriptionGets all attempted locales through the successful candidate.getKey()Gets the translation key.Gets the locale-negotiation diagnostics when available.Gets the locale used to begin per-key lookup.Gets the failures preceding the successful candidate.Gets the locale that supplied the translation.toString()
-
Constructor Details
-
TranslationFallbackEvent
public TranslationFallbackEvent(@NonNull TranslationResult translationResult, @NonNull List<@NonNull TranslationFallbackEvent.PrecedingFailure> precedingFailures) Constructs an event from a successful result and the failures preceding it. CustomStringsimplementations can use this constructor to expose the same diagnostics.The locale-match result and unmodifiable attempted-locales list are shared with
translationResult. The supplied failure list is defensively copied. This event does not retain the rendered translation fromtranslationResult.- Parameters:
translationResult- a translated result whose successful locale follows at least one failed candidate, not nullprecedingFailures- failures for every preceding candidate, in attempt order, not null- Throws:
IllegalArgumentException- if the result is not translated, there are no preceding candidates, or the failures do not correspond exactly to the preceding attempted locales
-
-
Method Details
-
getKey
-
getLookupLocale
Gets the locale used to begin per-key lookup.- Returns:
- lookup locale, not null
-
getLocaleMatchResult
Gets the locale-negotiation diagnostics when available.- Returns:
- locale-match result when available, otherwise empty, not null
-
getAttemptedLocales
Gets all attempted locales through the successful candidate.- Returns:
- attempted locales in attempt order, not null
-
getResolvedLocale
Gets the locale that supplied the translation.- Returns:
- resolved locale, not null
-
getPrecedingFailures
Gets the failures preceding the successful candidate.- Returns:
- preceding failures in attempt order, not null
-
toString
-