Package io.confound.config
Class StringMapConfiguration
- java.lang.Object
-
- io.confound.config.AbstractConfiguration
-
- io.confound.config.BaseConfiguration<java.lang.String>
-
- io.confound.config.AbstractStringConfiguration
-
- io.confound.config.StringMapConfiguration
-
- All Implemented Interfaces:
Configuration
,Parameters
public class StringMapConfiguration extends AbstractStringConfiguration
Configuration implementation backed by aMap
with string values.- Author:
- Garret Wilson
- See Also:
Map
,Map.get(Object)
-
-
Constructor Summary
Constructors Constructor Description StringMapConfiguration(java.util.Map<java.lang.String,java.lang.String> map)
Map constructor.StringMapConfiguration(java.util.Map<java.lang.String,java.lang.String> map, Configuration parentConfiguration)
Parent configuration and map constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Optional<java.lang.String>
findParameterImpl(java.lang.String key)
Implementation to retrieves a general parameter that may not be present from the underlying storage.protected boolean
hasParameterImpl(java.lang.String key)
Determines whether a parameter is present in the underlying storage.-
Methods inherited from class io.confound.config.AbstractStringConfiguration
dereferenceString, findParameter, getOptionalBoolean, getOptionalDouble, getOptionalInt, getOptionalLong, getOptionalPath, getOptionalString, getOptionalUri
-
Methods inherited from class io.confound.config.BaseConfiguration
getOptionalParameter, hasParameter, normalizeKey
-
Methods inherited from class io.confound.config.AbstractConfiguration
getParentConfiguration, 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.Parameters
getBoolean, getDouble, getInt, getLong, getParameter, getPath, getString, getUri, requireParameter, resolvePath
-
-
-
-
Constructor Detail
-
StringMapConfiguration
public StringMapConfiguration(@Nonnull java.util.Map<java.lang.String,java.lang.String> map)
Map constructor.- Parameters:
map
- The map to back this configuration.- Throws:
java.lang.NullPointerException
- if the given map isnull
.
-
StringMapConfiguration
public StringMapConfiguration(@Nonnull java.util.Map<java.lang.String,java.lang.String> map, @Nullable Configuration parentConfiguration)
Parent configuration and map constructor.- Parameters:
map
- The map to back this configuration.parentConfiguration
- The parent configuration to use for fallback lookup, ornull
if there is no parent configuration.- Throws:
java.lang.NullPointerException
- if the given map isnull
.
-
-
Method Detail
-
hasParameterImpl
protected boolean hasParameterImpl(java.lang.String key) throws ConfigurationException
Determines whether a parameter is present in the underlying storage.The given parameter key is assumed to already be normalized, and should not be modified.
This method must not fall back to parent configuration; only local values must be returned.
The default implementation delegates to
This implementation delegates toBaseConfiguration.findParameterImpl(String)
.Map.containsKey(Object)
.- Overrides:
hasParameterImpl
in classBaseConfiguration<java.lang.String>
- Parameters:
key
- The normalized parameter key.- Returns:
true
if a parameter of type type could be retrieved from these parameters using the given key.- Throws:
ConfigurationException
- if there is a parameter value stored in an invalid format.
-
findParameterImpl
protected java.util.Optional<java.lang.String> findParameterImpl(java.lang.String key) throws ConfigurationException
Implementation to retrieves a general parameter that may not be present from the underlying storage.The given parameter key is assumed to already be normalized, and should not be modified.
This method must not fall back to parent configuration; only local values must be returned.
This implementation delegates toMap.get(Object)
.- Specified by:
findParameterImpl
in classBaseConfiguration<java.lang.String>
- Parameters:
key
- The normalized parameter key.- Returns:
- The optional value of the parameter associated with the given key.
- Throws:
ConfigurationException
- if there is a parameter value stored in an invalid format.
-
-