Package io.rincl

Class 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
    • 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 io.confound.config.AbstractConfiguration

        or
      • 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
    • 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 is null.
    • Method Detail

      • getContextClass

        public java.lang.Class<?> getContextClass()
        Specified by:
        getContextClass in interface Resources
        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 interface Resources
        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)