Package io.rincl
Class EmptyResourceI18nConcern
java.lang.Object
io.rincl.EmptyResourceI18nConcern
- All Implemented Interfaces:
io.csar.Concern
,LocaleSelectable
,ResourceI18nConcern
,ResourcesFactory
Resource internationalization concern that returns an empty set of resources.
The locale retrieval and setting methods merely delegate to the JVM defaults.
This implementation is useful for use in an unconfigured context in which all calling code provides default resources in the case of a missing resource.
- Author:
- Garret Wilson
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final EmptyResourceI18nConcern
Singleton instance of the resource i18n concern returning empty resources.Fields inherited from interface io.rincl.ResourcesFactory
NONE
-
Method Summary
Modifier and TypeMethodDescriptionfindResources
(Class<?> contextClass, Locale locale) Retrieves resources related to a specified locale for the given context class.getLocale
(Locale.Category category) Retrieves the configured locale for the given category.void
setLocale
(Locale.Category category, Locale locale) Configures the locale for the given locale category.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.rincl.LocaleSelectable
setLocale
Methods inherited from interface io.rincl.ResourceI18nConcern
getConcernType, getResources, getResources
Methods inherited from interface io.rincl.ResourcesFactory
findResources, getResources, getResources
-
Field Details
-
INSTANCE
Singleton instance of the resource i18n concern returning empty resources.
-
-
Method Details
-
getLocale
Retrieves the configured locale for the given category.This implementation delegates to
Locale.getDefault(Category)
.- Specified by:
getLocale
in interfaceLocaleSelectable
- Parameters:
category
- The category of locale to return.- Returns:
- The the configured locale for the given category.
- See Also:
-
setLocale
Configures the locale for the given locale category. Future calls toLocaleSelectable.getLocale(Locale.Category)
will return the value set here.This implementation delegates to
Locale.setDefault(Category, Locale)
.- Specified by:
setLocale
in interfaceLocaleSelectable
- Parameters:
category
- The category for which the locale should be set.locale
- The new locale value.- See Also:
-
findResources
public Optional<Resources> findResources(Class<?> contextClass, Locale locale) throws io.confound.config.ConfigurationException Retrieves resources related to a specified locale for the given context class.The context class returned by
Resources.getContextClass()
may not necessarily be the context class provided here.This implementation returns an instance of
EmptyResources
.- Specified by:
findResources
in interfaceResourcesFactory
- Parameters:
contextClass
- The context with which these resources are related; usually the class of the object requesting the resource.locale
- The locale for which resources should be returned for the given context class.- Returns:
- Access to configured resources for the given context class.
- Throws:
io.confound.config.ConfigurationException
- if there is a configuration error.- See Also:
-