Class AbstractTranslationStore<T>
- Type Parameters:
T- the value of the translation store
- All Implemented Interfaces:
TranslationStore<T>, Translator
- Direct Known Subclasses:
AbstractTranslationStore.StringBased
- Since:
- 4.20.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn abstract, string-based translation store. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractTranslationStore(Key name) Creates a new abstract translation store with a given name. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleancanTranslate(String key, Locale locale) Checks if this translator can translate the given key and locale pair.final booleanChecks if any translations are explicitly registered for the specified key.final booleanChecks if any translations are explicitly registered for the specified key and locale.final voiddefaultLocale(Locale locale) Sets the default locale used by this store.final booleanfinal TriStateChecks if this translator has any translations.final inthashCode()final Keyname()A key identifying this translation source.final voidRegisters a translation.final voidregisterAll(Locale locale, Map<String, T> translations) Registers a map of translations.final voidRegisters translations with a set of keys and a mapping function to produce the translation from the key.toString()protected @Nullable TtranslationValue(String key, Locale locale) Returns a translation for a given key and locale, if any.final voidunregister(String key) Unregisters a translation key.Methods inherited from interface Translator
translate, translate
-
Constructor Details
-
AbstractTranslationStore
Creates a new abstract translation store with a given name.- Parameters:
name- the name- Since:
- 4.20.0
-
-
Method Details
-
translationValue
-
contains
Description copied from interface:TranslationStoreChecks if any translations are explicitly registered for the specified key.- Specified by:
containsin interfaceTranslationStore<T>- Parameters:
key- a translation key- Returns:
- whether the store contains a value for the translation key
-
contains
Description copied from interface:TranslationStoreChecks if any translations are explicitly registered for the specified key and locale.Note that this method is different from
TranslationStore.canTranslate(String, Locale)as this method does not check for translations in other locales (e.g., the default locale). This means that if a translation exists in the default locale for a given key (but not the provided locale),TranslationStore.canTranslate(String, Locale)would returntruebut this method would returnfalse.- Specified by:
containsin interfaceTranslationStore<T>- Parameters:
key- a translation keylocale- the locale- Returns:
- whether the store contains a value for the translation key and locale
- See Also:
-
canTranslate
Description copied from interface:TranslationStoreChecks if this translator can translate the given key and locale pair.Note that this method is different from
TranslationStore.contains(String, Locale)as this method checks for translations in other locales (e.g., the default locale). This means that if a translation exists in the default locale for a given key (but not the provided locale),TranslationStore.contains(String, Locale)would returnfalsebut this method would returntrue.- Specified by:
canTranslatein interfaceTranslationStore<T>- Specified by:
canTranslatein interfaceTranslator- Parameters:
key- the keylocale- the locale- Returns:
trueif this translator will return a non-null value for either of the twotranslatemethods- See Also:
-
defaultLocale
Description copied from interface:TranslationStoreSets the default locale used by this store.- Specified by:
defaultLocalein interfaceTranslationStore<T>- Parameters:
locale- the locale to use a default
-
register
Description copied from interface:TranslationStoreRegisters a translation.- Specified by:
registerin interfaceTranslationStore<T>- Parameters:
key- a translation keylocale- a localetranslation- the translation
-
registerAll
Description copied from interface:TranslationStoreRegisters a map of translations.- Specified by:
registerAllin interfaceTranslationStore<T>- Parameters:
locale- a localetranslations- a map of translation keys to translations- See Also:
-
registerAll
Description copied from interface:TranslationStoreRegisters translations with a set of keys and a mapping function to produce the translation from the key.- Specified by:
registerAllin interfaceTranslationStore<T>- Parameters:
locale- a localekeys- the translation keys to registerfunction- a function to transform a key into a message format
-
unregister
Description copied from interface:TranslationStoreUnregisters a translation key.- Specified by:
unregisterin interfaceTranslationStore<T>- Parameters:
key- a translation key
-
name
Description copied from interface:TranslatorA key identifying this translation source.Intended to be used for display to users.
- Specified by:
namein interfaceTranslator- Returns:
- an identifier for this translation source
-
hasAnyTranslations
Description copied from interface:TranslatorChecks if this translator has any translations.- Specified by:
hasAnyTranslationsin interfaceTranslator- Returns:
TriState.TRUEif any,TriState.NOT_SETif unknown, orTriState.FALSEif none
-
equals
-
hashCode
-
toString
-