Package dev.orne.i18n.context
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:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAbstractI18nContextProvider.BuilderImpl<T extends AbstractI18nContextProvider,B extends AbstractI18nContextProvider.BuilderImpl<T, B>> Abstract builder of I18N context provider instances.Nested classes/interfaces inherited from interface dev.orne.i18n.context.I18nContextProvider
I18nContextProvider.Builder, I18nContextProvider.Configurer, I18nContextProvider.Registry - 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractI18nContextProvider(@NotNull AbstractI18nContextProvider.BuilderImpl<?, ?> builder) Creates a new instance based on specified builder. - 
Method Summary
Modifier and TypeMethodDescription@NotNull I18nContextCreates a new I18N context with default values.@NotNull I18nContextcreateContext(@NotNull I18nContext parent) Creates a new I18N context with values inherited from the specified parent I18N context.boolean@NotNull Locale[]Returns the supported languages.@NotNull I18nResourcesReturns the default I18N resources.Returns the default locale supplier.@NotNull Map<@NotNull String,@NotNull I18nResources> Returns the alternative I18N resources by key.@NotNull I18nResourcesgetI18nResources(String key) Returns the I18N resources identified by the specified key.@NotNull UUIDReturns the UUID of this provider instance and session.inthashCode()voidInvalidates this context provider, thus invalidating any previously created I18N contexts.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.orne.i18n.context.I18nContextProvider
clearContext, getContext, isContextValid 
- 
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
Returns the UUID of this provider instance and session. Used to check contexts validity. Constant from instance creation to call toinvalidate()- Returns:
 - The UUID of this provider instance
 
 - 
getDefaultLocaleSupplier
Returns the default locale supplier.- Returns:
 - The default locale supplier.
 
 - 
getAvailableLocales
Returns the supported languages.- Specified by:
 getAvailableLocalesin interfaceI18nContextProvider- Returns:
 - The supported languages
 
 - 
getDefaultI18nResources
Returns the default I18N resources.- Specified by:
 getDefaultI18nResourcesin interfaceI18nContextProvider- Returns:
 - The default I18N resources
 
 - 
getI18nResources
Returns the alternative I18N resources by key.- Returns:
 - The alternative I18N resources by key
 
 - 
getI18nResources
Returns the I18N resources identified by the specified key. If key isnullor no resources is associated for such key returns the default I18N resources.- Specified by:
 getI18nResourcesin interfaceI18nContextProvider- Parameters:
 key- The key of the alternative I18N resources- Returns:
 - The I18N resources to use for the key
 
 - 
createContext
Creates a new I18N context with default values.- Returns:
 - The new I18N context
 
 - 
createContext
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:
 invalidatein interfaceI18nContextProvider
 - 
hashCode
public int hashCode() - 
equals
 
 -