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
Modifier and TypeClassDescriptionstatic interface
Interface forThreadI18nContextProvider
instance builders.protected static class
ThreadI18nContextProvider.BuilderImpl<T extends ThreadI18nContextProvider,
B extends ThreadI18nContextProvider.BuilderImpl<T, B>> Abstract builder ofThreadI18nContextProvider
instances.static class
Factory forThreadI18nContextProvider
instances.Nested classes/interfaces inherited from interface dev.orne.i18n.context.I18nContextProvider
I18nContextProvider.Configurer, I18nContextProvider.Registry
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
ThreadI18nContextProvider
(@NotNull ThreadI18nContextProvider.BuilderImpl<?, ?> builder) Creates a new instance based on specified builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ThreadI18nContextProvider.Builder
builder()
Creates a newThreadI18nContextProvider
instances builder.void
Clears the I18N context for the current thread.boolean
@NotNull I18nContext
Return theI18nContext
associated with the currentThread
.protected @NotNull ThreadLocal<I18nContext>
Returns the internalI18nContext
s perThread
container.int
hashCode()
boolean
isContextValid
(@NotNull I18nContext context) The default contexts don't expire.boolean
Returnstrue
if theI18nContext
instances 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 newThreadI18nContextProvider
instances builder.- Returns:
- The
ThreadI18nContextProvider
instances builder.
-
isInheritable
public boolean isInheritable()Returnstrue
if theI18nContext
instances will be inherited by child threads.- Returns:
- If the
I18nContext
instances will be inherited by child threads.
-
getContexts
Returns the internalI18nContext
s perThread
container.- Returns:
- The
I18nContext
s perThread
container
-
getContext
Return theI18nContext
associated with the currentThread
.If no
I18nContext
exists for the currentThread
or 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:
true
if the specified context is valid
-
clearContext
public void clearContext()Clears the I18N context for the current thread. -
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractI18nContextProvider
-
equals
- Overrides:
equals
in classAbstractI18nContextProvider
-