public abstract class AbstractResourceI18nConcern extends Object implements ResourceI18nConcern
This class provides an implementation of getLocale(Locale.Category)
and ResourceI18nConcern.setLocale(Locale)
.
Constructor and Description |
---|
AbstractResourceI18nConcern()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
Locale |
getLocale(Locale.Category category)
Retrieves the configured locale for the given category.
|
protected Optional<Resources> |
getParentResources(Class<?> contextClass)
Retrieves parent resources for the given context.
|
void |
setLocale(Locale.Category category,
Locale locale)
Configures the locale for this concern instance for the given locale category.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConcernType, getResources, setLocale
public AbstractResourceI18nConcern()
public Locale getLocale(@Nonnull Locale.Category category)
ResourceI18nConcern
If no category has been configured for this concern instance, this method delegates to Locale.getDefault(Locale.Category)
.
getLocale
in interface ResourceI18nConcern
category
- The category of locale to return.ResourceI18nConcern.setLocale(Locale.Category, Locale)
,
Locale.getDefault(Locale.Category)
public void setLocale(@Nonnull Locale.Category category, @Nonnull Locale locale)
getLocale(Locale.Category)
will return the value
set here.
This method does not modify the default JVM locale.
setLocale
in interface ResourceI18nConcern
category
- The category for which the locale should be set..locale
- The new locale value.NullPointerException
- if the given category and/or new locale is null
.getLocale(Locale.Category)
protected Optional<Resources> getParentResources(@Nonnull Class<?> contextClass) throws ResourceConfigurationException
This method should be used by subclass ResourceI18nConcern.getResources(Class)
implementations to determine the parent resources to use.
The default implementation returns an empty optional.
contextClass
- The context with which these resources are related; usually the class of the object requesting the resource.NullPointerException
- if the given context class is null
.ResourceConfigurationException
- if there is a configuration error.Copyright © 2016 GlobalMentor, Inc.. All rights reserved.