Interface I18nContextProvider

All Known Implementing Classes:
AbstractI18nContextProvider, I18nSpringContextProvider, SharedI18nContextProvider, ThreadI18nContextProvider

@API(status=STABLE, since="0.1") public interface I18nContextProvider
Provider of I18nContext instances. Provides methods to create new I18n contexts, to check if a given context is still alive and to access default I18N resources of the application.
Since:
0.1
Version:
1.0, 2021-01
Author:
(w) Iker Hernaez
See Also:
  • Method Details

    • getInstance

      @API(status=EXPERIMENTAL, since="0.1") @NotNull static @NotNull I18nContextProvider getInstance()
      Returns the I18N context provider.
      Returns:
      The I18N context provider.
    • getAvailableLocales

      @NotNull @NotNull Locale[] getAvailableLocales()
      Returns the supported languages.
      Returns:
      The supported languages
    • getDefaultI18nResources

      @NotNull @NotNull I18nResources getDefaultI18nResources()
      Returns the default I18N resources.
      Returns:
      The default I18N resources
    • getI18nResources

      @NotNull @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.
      Parameters:
      key - The key of the alternative I18N resources
      Returns:
      The I18N resources to use for the key
    • getContext

      @NotNull @NotNull I18nContext getContext()
      Return the I18nContext associated with the current Thread.

      If no I18nContext exists for the current Thread or the existing one is not alive anymore a new one is created.

      Returns:
      The current I18nContext. Never null.
    • isContextValid

      boolean isContextValid(@NotNull @NotNull I18nContext context)
      Returns true if the specified context is valid or should be discarded.
      Parameters:
      context - The I18N context
      Returns:
      true if the specified context is valid
    • clearContext

      void clearContext()
      Clears the I18N context for the current thread.
    • invalidate

      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.