Package io.confound.config
Interface Parameters
-
- All Known Subinterfaces:
Configuration
- All Known Implementing Classes:
AbstractConfiguration
,AbstractObjectConfiguration
,AbstractParametersDecorator
,AbstractStringConfiguration
,BaseConfiguration
,EmptyConfiguration
,ManagedConfiguration
,ObjectMapConfiguration
,StringMapConfiguration
public interface Parameters
General access to configuration parameters.- Author:
- Garret Wilson
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
getBoolean(java.lang.String key)
Retrieves a Boolean parameter.default double
getDouble(java.lang.String key)
Retrieves a floating point parameter.default int
getInt(java.lang.String key)
Retrieves an integer parameter.default int
getLong(java.lang.String key)
Retrieves a long integer parameter.java.util.Optional<java.lang.Boolean>
getOptionalBoolean(java.lang.String key)
Retrieves a Boolean parameter that may not be present.java.util.Optional<java.lang.Double>
getOptionalDouble(java.lang.String key)
Retrieves a floating point parameter that may not be present.java.util.Optional<java.lang.Integer>
getOptionalInt(java.lang.String key)
Retrieves an integer parameter that may not be present.default java.util.Optional<java.lang.Long>
getOptionalLong(java.lang.String key)
Retrieves a long integer parameter that may not be present.<P> java.util.Optional<P>
getOptionalParameter(java.lang.String key)
Retrieves a general parameter that may not be present.java.util.Optional<java.nio.file.Path>
getOptionalPath(java.lang.String key)
Retrieves a path parameter that may not be present.java.util.Optional<java.lang.String>
getOptionalString(java.lang.String key)
Retrieves a string parameter that may not be present.java.util.Optional<java.net.URI>
getOptionalUri(java.lang.String key)
Retrieves a URI parameter that may not be present.default <P> P
getParameter(java.lang.String key)
Retrieves a general parameter.default java.nio.file.Path
getPath(java.lang.String key)
Retrieves a path parameter.default java.lang.String
getString(java.lang.String key)
Retrieves a string parameter.default java.net.URI
getUri(java.lang.String key)
Retrieves a URI parameter.boolean
hasParameter(java.lang.String key)
Determines whether a parameter of some type exists for the given parameter key.default <P> P
requireParameter(java.util.Optional<P> parameter, java.lang.String key)
Retrieves a required parameter from anOptional
, throwing aMissingParameterException
if the parameter not present.default java.nio.file.Path
resolvePath(java.nio.file.Path path)
Resolves the given path as appropriate.
-
-
-
Method Detail
-
requireParameter
default <P> P requireParameter(@Nonnull java.util.Optional<P> parameter, @Nonnull java.lang.String key) throws MissingParameterException
Retrieves a required parameter from anOptional
, throwing aMissingParameterException
if the parameter not present.This method is primarily used to check the result of a parameter lookup call for the non-optional convenience parameter lookup versions.
- Type Parameters:
P
- The type of parameter to check.- Parameters:
parameter
- The retrieved parameter.key
- The parameter key.- Returns:
- The retrieved parameter.
- Throws:
MissingParameterException
- if the given parameter is not present.- See Also:
Optional.isPresent()
-
hasParameter
boolean hasParameter(@Nonnull java.lang.String key) throws ConfigurationException
Determines whether a parameter of some type exists for the given parameter key.- Parameters:
key
- The parameter key.- Returns:
true
if a parameter of type type could be retrieved from these parameters using the given key.- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getParameter
@Nonnull default <P> P getParameter(@Nonnull java.lang.String key) throws MissingParameterException, ConfigurationException
Retrieves a general parameter.- Type Parameters:
P
- The type of parameter expected.- Parameters:
key
- The parameter key.- Returns:
- The value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.MissingParameterException
- if no parameter is associated with the given key.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getOptionalParameter
<P> java.util.Optional<P> getOptionalParameter(@Nonnull java.lang.String key) throws ConfigurationException
Retrieves a general parameter that may not be present.- Type Parameters:
P
- The type of parameter expected.- Parameters:
key
- The parameter key.- Returns:
- The optional value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getBoolean
@Nonnull default boolean getBoolean(@Nonnull java.lang.String key) throws MissingParameterException, ConfigurationException
Retrieves a Boolean parameter.- Parameters:
key
- The parameter key.- Returns:
- The value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.MissingParameterException
- if no parameter is associated with the given key.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getOptionalBoolean
java.util.Optional<java.lang.Boolean> getOptionalBoolean(@Nonnull java.lang.String key) throws ConfigurationException
Retrieves a Boolean parameter that may not be present.- Parameters:
key
- The parameter key.- Returns:
- The optional value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getDouble
@Nonnull default double getDouble(@Nonnull java.lang.String key) throws MissingParameterException, ConfigurationException
Retrieves a floating point parameter.- Parameters:
key
- The parameter key.- Returns:
- The value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.MissingParameterException
- if no parameter is associated with the given key.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getOptionalDouble
java.util.Optional<java.lang.Double> getOptionalDouble(@Nonnull java.lang.String key) throws ConfigurationException
Retrieves a floating point parameter that may not be present.- Parameters:
key
- The parameter key.- Returns:
- The optional value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getInt
@Nonnull default int getInt(@Nonnull java.lang.String key) throws MissingParameterException, ConfigurationException
Retrieves an integer parameter.- Parameters:
key
- The parameter key.- Returns:
- The value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.MissingParameterException
- if no parameter is associated with the given key.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getOptionalInt
java.util.Optional<java.lang.Integer> getOptionalInt(@Nonnull java.lang.String key) throws ConfigurationException
Retrieves an integer parameter that may not be present.- Parameters:
key
- The parameter key.- Returns:
- The optional value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getLong
@Nonnull default int getLong(@Nonnull java.lang.String key) throws MissingParameterException, ConfigurationException
Retrieves a long integer parameter.- Parameters:
key
- The parameter key.- Returns:
- The value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.MissingParameterException
- if no parameter is associated with the given key.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getOptionalLong
default java.util.Optional<java.lang.Long> getOptionalLong(@Nonnull java.lang.String key) throws ConfigurationException
Retrieves a long integer parameter that may not be present.The default implementation delegates to
getOptionalInt(String)
.- Parameters:
key
- The parameter key.- Returns:
- The optional value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getPath
@Nonnull default java.nio.file.Path getPath(@Nonnull java.lang.String key) throws MissingParameterException, ConfigurationException
Retrieves a path parameter.The path will be resolved using
resolvePath(Path)
.- Parameters:
key
- The parameter key.- Returns:
- The value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.MissingParameterException
- if no parameter is associated with the given key.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getOptionalPath
java.util.Optional<java.nio.file.Path> getOptionalPath(@Nonnull java.lang.String key) throws ConfigurationException
Retrieves a path parameter that may not be present.The path will be resolved using
resolvePath(Path)
.- Parameters:
key
- The parameter key.- Returns:
- The optional value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
resolvePath
default java.nio.file.Path resolvePath(@Nonnull java.nio.file.Path path)
Resolves the given path as appropriate. Absolute paths should not be modified. Relative paths may be resolved to some standard or configured absolute path, depending on the implementation. A common base path may be configured separately, stored elsewhere in the parameters, or encoded in the path string itself for example.The default implementation merely returns the given path.
- Parameters:
path
- The path to resolve.- Returns:
- A resolved form of the path if appropriate.
-
getString
@Nonnull default java.lang.String getString(@Nonnull java.lang.String key) throws MissingParameterException, ConfigurationException
Retrieves a string parameter.TODO discuss dereferencing
- Parameters:
key
- The parameter key.- Returns:
- The value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.MissingParameterException
- if no parameter is associated with the given key.ConfigurationException
- if there is a parameter value stored in an invalid format.- See Also:
Format.format(Object)
-
getOptionalString
java.util.Optional<java.lang.String> getOptionalString(@Nonnull java.lang.String key) throws ConfigurationException
Retrieves a string parameter that may not be present.TODO discuss dereferencing
- Parameters:
key
- The parameter key.- Returns:
- The optional value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.ConfigurationException
- if there is a parameter value stored in an invalid format.- See Also:
Format.format(Object)
-
getUri
@Nonnull default java.net.URI getUri(@Nonnull java.lang.String key) throws MissingParameterException, ConfigurationException
Retrieves a URI parameter.- Parameters:
key
- The parameter key.- Returns:
- The value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.MissingParameterException
- if no parameter is associated with the given key.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
getOptionalUri
java.util.Optional<java.net.URI> getOptionalUri(@Nonnull java.lang.String key) throws ConfigurationException
Retrieves a URI parameter that may not be present.- Parameters:
key
- The parameter key.- Returns:
- The optional value of the parameter associated with the given key.
- Throws:
java.lang.NullPointerException
- if the given key isnull
.java.lang.SecurityException
- If a security manager exists and it doesn't allow access to the specified parameter.ConfigurationException
- if there is a parameter value stored in an invalid format.
-
-