Class AbstractTranslationStore<T>
- Type Parameters:
T- the value of the translation store
- All Implemented Interfaces:
TranslationStore<T>,Translator,net.kyori.examination.Examinable
- 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(@NotNull Key name) Creates a new abstract translation store with a given name. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleancanTranslate(@NotNull String key, @NotNull 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(@NotNull Locale locale) Sets the default locale used by this store.final booleanfinal @NotNull Stream<? extends net.kyori.examination.ExaminableProperty>final @NotNull TriStateChecks if this translator has any translations.final inthashCode()final @NotNull Keyname()A key identifying this translation source.final voidRegisters a translation.final voidregisterAll(@NotNull Locale locale, @NotNull 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.final @NotNull StringtoString()protected TtranslationValue(@NotNull String key, @NotNull Locale locale) Returns a translation for a given key and locale, if any.final voidunregister(@NotNull String key) Unregisters a translation key.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.kyori.examination.Examinable
examinableName, examineMethods inherited from interface net.kyori.adventure.translation.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
@Nullable protected T translationValue(@NotNull @NotNull String key, @NotNull @NotNull Locale locale) Returns a translation for a given key and locale, if any.- Parameters:
key- the keylocale- the locale- Returns:
- the translation, or
nullif none exists for this key - Since:
- 4.20.0
-
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
public final void register(@NotNull @NotNull String key, @NotNull @NotNull Locale locale, @NotNull T translation) Description copied from interface:TranslationStoreRegisters a translation.- Specified by:
registerin interfaceTranslationStore<T>- Parameters:
key- a translation keylocale- a localetranslation- the translation
-
registerAll
public final void registerAll(@NotNull @NotNull Locale locale, @NotNull @NotNull Map<String, T> translations) 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
public final void registerAll(@NotNull @NotNull Locale locale, @NotNull @NotNull Set<String> keys, Function<String, T> function) 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
-
examinableProperties
@NotNull public final @NotNull Stream<? extends net.kyori.examination.ExaminableProperty> examinableProperties()- Specified by:
examinablePropertiesin interfacenet.kyori.examination.Examinable
-
equals
-
hashCode
public final int hashCode() -
toString
-