Package dev.orne.i18n.context
Class ThreadI18nContextProvider
java.lang.Object
dev.orne.i18n.context.AbstractI18nContextProvider
dev.orne.i18n.context.ThreadI18nContextProvider
- All Implemented Interfaces:
I18nContextProvider
- Direct Known Subclasses:
I18nSpringContextProvider
@API(status=STABLE,
since="0.1")
public class ThreadI18nContextProvider
extends AbstractI18nContextProvider
Implementation of
I18nContextProvider that provides a
different I18nContext for each thread.- Since:
- 0.1
- Version:
- 2.0, 2022-12
- Author:
- (w) Iker Hernaez
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface forThreadI18nContextProviderinstance builders.protected static classThreadI18nContextProvider.BuilderImpl<T extends ThreadI18nContextProvider,B extends ThreadI18nContextProvider.BuilderImpl<T, B>> Abstract builder ofThreadI18nContextProviderinstances.static classFactory forThreadI18nContextProviderinstances.Nested classes/interfaces inherited from interface dev.orne.i18n.context.I18nContextProvider
I18nContextProvider.Configurer, I18nContextProvider.Registry -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThreadI18nContextProvider(@NotNull ThreadI18nContextProvider.BuilderImpl<?, ?> builder) Creates a new instance based on specified builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ThreadI18nContextProvider.Builderbuilder()Creates a newThreadI18nContextProviderinstances builder.voidClears the I18N context for the current thread.boolean@NotNull I18nContextReturn theI18nContextassociated with the currentThread.protected @NotNull ThreadLocal<I18nContext>Returns the internalI18nContexts perThreadcontainer.inthashCode()booleanisContextValid(@NotNull I18nContext context) The default contexts don't expire.booleanReturnstrueif theI18nContextinstances will be inherited by child threads.Methods inherited from class dev.orne.i18n.context.AbstractI18nContextProvider
createContext, createContext, getAvailableLocales, getDefaultI18nResources, getDefaultLocaleSupplier, getI18nResources, getI18nResources, getSessionUUID, invalidate
-
Field Details
-
TYPE
The I18N context provider type.- See Also:
-
-
Constructor Details
-
ThreadI18nContextProvider
protected ThreadI18nContextProvider(@NotNull @NotNull ThreadI18nContextProvider.BuilderImpl<?, ?> builder) Creates a new instance based on specified builder.- Parameters:
builder- The I18N context provider builder.
-
-
Method Details
-
builder
Creates a newThreadI18nContextProviderinstances builder.- Returns:
- The
ThreadI18nContextProviderinstances builder.
-
isInheritable
public boolean isInheritable()Returnstrueif theI18nContextinstances will be inherited by child threads.- Returns:
- If the
I18nContextinstances will be inherited by child threads.
-
getContexts
Returns the internalI18nContexts perThreadcontainer.- Returns:
- The
I18nContexts perThreadcontainer
-
getContext
Return theI18nContextassociated with the currentThread.If no
I18nContextexists for the currentThreador the existing one is not alive anymore a new one is created.- Returns:
- The current
I18nContext. Nevernull.
-
isContextValid
The default contexts don't expire.- Parameters:
context- The I18N context- Returns:
trueif the specified context is valid
-
clearContext
public void clearContext()Clears the I18N context for the current thread. -
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractI18nContextProvider
-
equals
- Overrides:
equalsin classAbstractI18nContextProvider
-