Package dev.orne.i18n.context
Class SharedI18nContextProvider
java.lang.Object
dev.orne.i18n.context.AbstractI18nContextProvider
dev.orne.i18n.context.SharedI18nContextProvider
- All Implemented Interfaces:
I18nContextProvider
@API(status=STABLE,
since="0.1")
public class SharedI18nContextProvider
extends AbstractI18nContextProvider
Implementation of
I18nContextProvider
that shares a single
I18nContext
instance for all threads.- Since:
- 0.2
- Version:
- 1.0, 2022-10
- Author:
- (w) Iker Hernaez
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface forSharedI18nContextProvider
instance builders.protected static class
SharedI18nContextProvider.BuilderImpl<T extends SharedI18nContextProvider,
B extends SharedI18nContextProvider.BuilderImpl<T, B>> Builder ofSharedI18nContextProvider
instances.static class
Factory forSharedI18nContextProvider
instances.Nested classes/interfaces inherited from interface dev.orne.i18n.context.I18nContextProvider
I18nContextProvider.Configurer, I18nContextProvider.Registry
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
SharedI18nContextProvider
(@NotNull SharedI18nContextProvider.BuilderImpl<?, ?> builder) Creates a new instance based on specified builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull SharedI18nContextProvider.Builder
builder()
Creates a newSharedI18nContextProvider
instances builder.void
Clears the I18N context for the current thread.boolean
@NotNull I18nContext
Return theI18nContext
associated with the currentThread
.int
hashCode()
boolean
isContextValid
(@NotNull I18nContext context) Returnstrue
if the specified context is valid or should be discarded.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
-
Method Details
-
builder
Creates a newSharedI18nContextProvider
instances builder.- Returns:
- The
SharedI18nContextProvider
instances builder.
-
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
Returnstrue
if the specified context is valid or should be discarded.- 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
-