T
- pool object type.private static class I18nPoolFactory.LocalePool<T> extends Object implements I18nPool<T>
Modifier and Type | Field and Description |
---|---|
private Map<String,Map<String,T>> |
localeMaps
Locale sensitive cache storage.
|
Modifier | Constructor and Description |
---|---|
private |
LocalePool() |
Modifier and Type | Method and Description |
---|---|
T |
get(String name,
Locale... locale)
Get instance identified by name and optional locale settings.
|
boolean |
has(String name,
Locale... locale)
Test if cache has an instance identified by given name and optional locale settings.
|
private Map<String,T> |
maps(Locale locale)
Get named objects map bound to requested locale settings.
|
boolean |
put(String name,
T t,
Locale... locale)
Store an instance on this cache bound to given name and optional locale settings.
|
private final Map<String,Map<String,T>> localeMaps
Locale.toLanguageTag()
. As requested by I18NPool interface locale
should be based only on language and optional country, encoded with ISO 639 alpha-2, respective ISO 3166 alpha-2;
script, variant and extension should be empty.
Implementation avoid using locale instances for map keys. Accordingly Java Locale API, ISO 639 alpha-2 language code
is not stable; there are updated language codes that will render in different keys. For example Locale("he") and
Locale("iw") will result in different map keys. Using locale language tag ensure always is used the new language
code, in previous example he
.
public boolean put(String name, T t, Locale... locale)
I18nPool
locale
argument is silently ignored and not even tested for validity.public T get(String name, Locale... locale)
I18nPool
locale
argument is silently ignored and not
even tested for validity.public boolean has(String name, Locale... locale)
I18nPool
locale
argument is silently ignored and not even tested for validity.private Map<String,T> maps(Locale locale)
locale
- locale settings to retrieve objects map for.IllegalArgumentException
- if locale
argument has variant, script or extension.Copyright © 2018. All rights reserved.