Class AbstractI18nContextProvider

java.lang.Object
dev.orne.i18n.context.AbstractI18nContextProvider
All Implemented Interfaces:
I18nContextProvider
Direct Known Subclasses:
SharedI18nContextProvider, ThreadI18nContextProvider

@API(status=STABLE, since="0.1") public abstract class AbstractI18nContextProvider extends Object implements I18nContextProvider
Abstract implementation of I18nContextProvider.
Since:
0.1
Version:
1.0, 2022-12
Author:
(w) Iker Hernaez
See Also:
  • Constructor Details

    • AbstractI18nContextProvider

      protected AbstractI18nContextProvider(@NotNull @NotNull AbstractI18nContextProvider.BuilderImpl<?,?> builder)
      Creates a new instance based on specified builder.
      Parameters:
      builder - The I18N context provider builder.
  • Method Details

    • getSessionUUID

      @NotNull public @NotNull UUID getSessionUUID()
      Returns the UUID of this provider instance and session. Used to check contexts validity. Constant from instance creation to call to invalidate()
      Returns:
      The UUID of this provider instance
    • getDefaultLocaleSupplier

      @NotNull protected @NotNull Supplier<@NotNull Locale> getDefaultLocaleSupplier()
      Returns the default locale supplier.
      Returns:
      The default locale supplier.
    • getAvailableLocales

      @NotNull public @NotNull Locale[] getAvailableLocales()
      Returns the supported languages.
      Specified by:
      getAvailableLocales in interface I18nContextProvider
      Returns:
      The supported languages
    • getDefaultI18nResources

      @NotNull public @NotNull I18nResources getDefaultI18nResources()
      Returns the default I18N resources.
      Specified by:
      getDefaultI18nResources in interface I18nContextProvider
      Returns:
      The default I18N resources
    • getI18nResources

      @NotNull public @NotNull Map<@NotNull String,@NotNull I18nResources> getI18nResources()
      Returns the alternative I18N resources by key.
      Returns:
      The alternative I18N resources by key
    • getI18nResources

      @NotNull public @NotNull I18nResources getI18nResources(String key)
      Returns the I18N resources identified by the specified key. If key is null or no resources is associated for such key returns the default I18N resources.
      Specified by:
      getI18nResources in interface I18nContextProvider
      Parameters:
      key - The key of the alternative I18N resources
      Returns:
      The I18N resources to use for the key
    • createContext

      @NotNull public @NotNull I18nContext createContext()
      Creates a new I18N context with default values.
      Returns:
      The new I18N context
    • createContext

      @NotNull public @NotNull I18nContext createContext(@NotNull @NotNull I18nContext parent)
      Creates a new I18N context with values inherited from the specified parent I18N context.
      Parameters:
      parent - The parent I18N context
      Returns:
      The new I18N context
    • invalidate

      public void invalidate()
      Invalidates this context provider, thus invalidating any previously created I18N contexts.

      Effects of calling any other method after this one is left to implementations choice, and thus is discouraged.

      This implementation resets available languages, and I18N resources to defaults and generates a new session UUID to invalidate any existing contexts.

      Specified by:
      invalidate in interface I18nContextProvider
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object