Interface ResourcesFactory
- All Known Subinterfaces:
ResourceI18nConcern
- All Known Implementing Classes:
AbstractResourceI18nConcern
,BaseResourceI18nConcern
,EmptyResourceI18nConcern
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
- Author:
- Garret Wilson
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ResourcesFactory
Resources factory that returns no resources, and when resources are required returns an empty resources instance. -
Method Summary
Modifier and TypeMethodDescriptionfindResources
(Class<?> contextClass, Locale locale) Retrieves resources related to a specified locale for the given context class.findResources
(Object context, Locale locale) Retrieves resources related to a specified locale for the given context.default Resources
getResources
(Class<?> contextClass, Locale locale) Retrieves resources related to a specified locale for the given context class.default Resources
getResources
(Object context, Locale locale) Retrieves resources related to a specified locale for the given context.
-
Field Details
-
NONE
Resources factory that returns no resources, and when resources are required returns an empty resources instance.
-
-
Method Details
-
getResources
@Nonnull default Resources getResources(@Nonnull Object context, @Nonnull Locale locale) throws io.confound.config.ConfigurationException Retrieves resources related to a specified locale for the given context.The context class returned by
Resources.getContextClass()
may not necessarily reflect the class of the context provided here.The default implementation delegates to
findResources(Object, Locale)
.If no resources are available, empty resources will be returned.
- Parameters:
context
- The context with which these resources are related; usually the object requesting the resource.locale
- The locale for which resources should be returned for the given context.- Returns:
- Access to configured resources for the given context.
- Throws:
NullPointerException
- if the given context and/or locale isnull
.io.confound.config.ConfigurationException
- if there is a configuration error.- See Also:
-
getResources
@Nonnull default Resources getResources(@Nonnull Class<?> contextClass, @Nonnull 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.If no resources are available, empty resources will be returned.
- 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:
NullPointerException
- if the given context class and/or locale isnull
.io.confound.config.ConfigurationException
- if there is a configuration error.
-
findResources
@Nonnull default Optional<Resources> findResources(@Nonnull Object context, @Nonnull Locale locale) throws io.confound.config.ConfigurationException Retrieves resources related to a specified locale for the given context.The context class returned by
Resources.getContextClass()
may not necessarily reflect the class of the context provided here.The default implementation delegates to
findResources(Class, Locale)
providing the class of the given instance. Implementations of this interface should if at all possible implement the class-based resource lookup method variations and leave these default delegating method implementations so as to provide the most flexibility to consumers.- Parameters:
context
- The context with which these resources are related; usually the object requesting the resource.locale
- The locale for which resources should be returned for the given context.- Returns:
- Access to configured resources for the given context.
- Throws:
NullPointerException
- if the given context and/or locale isnull
.io.confound.config.ConfigurationException
- if there is a configuration error.- See Also:
-
findResources
@Nonnull Optional<Resources> findResources(@Nonnull Class<?> contextClass, @Nonnull 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.- 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:
NullPointerException
- if the given context class and/or locale isnull
.io.confound.config.ConfigurationException
- if there is a configuration error.
-