Package io.rincl
Class ChildResourcesDecorator
- java.lang.Object
-
- io.confound.config.AbstractConfiguration
-
- io.confound.config.AbstractChildConfigurationDecorator<C>
-
- io.confound.config.BaseChildConfigurationDecorator<Resources>
-
- io.rincl.ChildResourcesDecorator
-
- All Implemented Interfaces:
io.confound.config.Configuration
,Resources
public class ChildResourcesDecorator extends io.confound.config.BaseChildConfigurationDecorator<Resources> implements Resources
A wrapper resources that forwards calls to the decorated resources, falling back to a parent resources.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description ChildResourcesDecorator(Resources resources, Resources parentResources)
Wrapped resources and parent resources constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<java.lang.String>
findString(java.lang.String key, java.lang.Object... arguments)
Retrieves a string resource that may not be present.java.lang.Class<?>
getContextClass()
-
Methods inherited from class io.confound.config.BaseChildConfigurationDecorator
getConfiguration, getParentConfiguration
-
Methods inherited from class io.confound.config.AbstractChildConfigurationDecorator
findBoolean, findDouble, findInt, findLong, findObject, findObject, findPath, findString, findUri, getBoolean, getDouble, getInt, getLong, getObject, getObject, getPath, getString, getUri, hasConfigurationValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.confound.config.Configuration
findBoolean, findDouble, findInt, findLong, findObject, findObject, findPath, findString, findUri, getBoolean, getDouble, getInt, getLong, getObject, getObject, getPath, getString, getUri, hasConfigurationValue, requireConfiguration, resolvePath, withFallback
-
Methods inherited from interface io.rincl.Resources
createMissingConfigurationKeyException, getString, hasResource, withFallback
-
-
-
-
Constructor Detail
-
ChildResourcesDecorator
public ChildResourcesDecorator(@Nonnull Resources resources, @Nonnull Resources parentResources)
Wrapped resources and parent resources constructor.- Parameters:
resources
- The resources to decorate.parentResources
- The parent resources to use for fallback lookup.- Throws:
java.lang.NullPointerException
- if the given resources and/or parent resources isnull
.
-
-
Method Detail
-
getContextClass
public java.lang.Class<?> getContextClass()
- Specified by:
getContextClass
in interfaceResources
- Returns:
- The context with which these resources are related; usually the class of the object requesting the resource.
-
findString
public java.util.Optional<java.lang.String> findString(java.lang.String key, java.lang.Object... arguments) throws io.confound.config.ConfigurationException
Description copied from interface:Resources
Retrieves a string resource that may not be present.TODO discuss dereferencing
If arguments are provided, the string if present will be considered a template and formatted applying the given arguments. Formatting takes place after replacement of all internal resource references. The
MessageFormat
formatting rules will be used.This method should normally not be overridden or decorated.
- Specified by:
findString
in interfaceResources
- Parameters:
key
- The resource key.arguments
- The arguments for formatting, if any.- Returns:
- The optional value of the resource associated with the given key.
- Throws:
io.confound.config.ConfigurationException
- if there is a resource value stored in an invalid format.- See Also:
Configuration.findString(String)
,Format.format(Object)
-
-