Package io.confound.config
Class SubConfiguration
- java.lang.Object
-
- io.confound.config.AbstractConfiguration
-
- io.confound.config.AbstractConfigurationDecorator
-
- io.confound.config.SubConfiguration
-
- All Implemented Interfaces:
Configuration
public class SubConfiguration extends AbstractConfigurationDecorator
A configuration that decorates another configuration, providing a view of a subtree of the keyspace with some key prefix. The subconfiguration acts as a live view, but only has access to keys with the specified prefix plus 46, and those keys will effectively have the prefix and delimiter removed. For example if a key prefix offoo.bar
is specified, only keys from the decorating logically starting withfoo.bar.
would be accessible in the subconfiguration. A setting in a configuration with the keyfoo.bar.example
would be accessible in the subconfiguration asexample
.- Author:
- Garret Wilson
-
-
Field Summary
-
Fields inherited from interface io.confound.config.Configuration
KEY_SEGMENT_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description SubConfiguration(Configuration configuration, java.lang.String prefixKey)
Wrapped configuration constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Optional<java.lang.String>
decorateKey(java.lang.String key)
Transforms the key appropriately before it is passed to the decorated configuration.-
Methods inherited from class io.confound.config.AbstractConfigurationDecorator
findBoolean, findDouble, findInt, findLong, findObject, findObject, findPath, findString, findUri, getBoolean, getConfiguration, 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
createMissingConfigurationKeyException, requireConfiguration, resolvePath, subConfiguration, superConfiguration, withFallback
-
-
-
-
Constructor Detail
-
SubConfiguration
public SubConfiguration(@Nonnull Configuration configuration, @Nonnull java.lang.String prefixKey)
Wrapped configuration constructor.- Parameters:
configuration
- The configuration to decorate.prefixKey
- The prefix not including the final segment separator 46.- Throws:
java.lang.NullPointerException
- if the given configuration and/or prefix key isnull
.
-
-
Method Detail
-
decorateKey
protected java.util.Optional<java.lang.String> decorateKey(java.lang.String key)
Description copied from class:AbstractConfigurationDecorator
Transforms the key appropriately before it is passed to the decorated configuration. The key may be given some prefix or have some prefix removed, for example, or the case of the key may be changed.If no key is returned, it indicates that the given key does not represent a key in this configuration view. For example, if the decorator represents a subset of the decorator configuration only for those keys starting with
foo.
, this method would return an empty configuration if a key did not being withfoo.
.- Overrides:
decorateKey
in classAbstractConfigurationDecorator
- Parameters:
key
- The key as provided by the caller.- Returns:
- The key transformed appropriately to be passed to the wrapped configuration.
-
-