Interface StructuredConfigProperties
- All Known Implementing Classes:
EmptyStructuredConfigProperties
An instance of StructuredConfigProperties
is equivalent to a YAML mapping node. It has accessors for
reading scalar properties, getStructured(String)
for reading children which are
themselves mappings, and getStructuredList(String)
for reading children which are
sequences of mappings.
This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StructuredConfigProperties
empty()
Return an emptyStructuredConfigProperties
instance.getBoolean
(String name) Returns aBoolean
configuration property.default boolean
getBoolean
(String name, boolean defaultValue) Returns aBoolean
configuration property.Returns aDouble
configuration property.default double
Returns aDouble
configuration property.Returns aInteger
configuration property.default int
Returns aInteger
configuration property.Returns aLong
configuration property.default long
Returns aLong
configuration property.Returns a set of all configuration property keys.<T> List
<T> getScalarList
(String name, Class<T> scalarType) Returns aList
configuration property.default <T> List
<T> getScalarList
(String name, Class<T> scalarType, List<T> defaultValue) Returns aList
configuration property.Returns aString
configuration property.default String
Returns aString
configuration property.getStructured
(String name) Returns aStructuredConfigProperties
configuration property.default StructuredConfigProperties
getStructured
(String name, StructuredConfigProperties defaultValue) Returns aStructuredConfigProperties
configuration property.getStructuredList
(String name) Returns a list ofStructuredConfigProperties
configuration property.default List
<StructuredConfigProperties> getStructuredList
(String name, List<StructuredConfigProperties> defaultValue) Returns a list ofStructuredConfigProperties
configuration property.
-
Method Details
-
empty
Return an emptyStructuredConfigProperties
instance.Useful for walking the tree without checking for null. For example, to access a string key nested at .foo.bar.baz, call:
config.getStructured("foo", empty()).getStructured("bar", empty()).getString("baz")
. -
getString
Returns aString
configuration property.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException
- if the property is not a valid scalar string
-
getString
Returns aString
configuration property.- Returns:
- a
String
configuration property ordefaultValue
if a property withname
has not been configured - Throws:
ConfigurationException
- if the property is not a valid scalar string
-
getBoolean
Returns aBoolean
configuration property. Implementations should use the same rules asBoolean.parseBoolean(String)
for handling the values.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException
- if the property is not a valid scalar boolean
-
getBoolean
Returns aBoolean
configuration property.- Returns:
- a
Boolean
configuration property ordefaultValue
if a property withname
has not been configured - Throws:
ConfigurationException
- if the property is not a valid scalar boolean
-
getInt
Returns aInteger
configuration property.If the underlying config property is
Long
, it is converted toInteger
withLong.intValue()
which may result in loss of precision.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException
- if the property is not a valid scalar integer
-
getInt
Returns aInteger
configuration property.If the underlying config property is
Long
, it is converted toInteger
withLong.intValue()
which may result in loss of precision.- Returns:
- a
Integer
configuration property ordefaultValue
if a property withname
has not been configured - Throws:
ConfigurationException
- if the property is not a valid scalar integer
-
getLong
Returns aLong
configuration property.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException
- if the property is not a valid scalar long
-
getLong
Returns aLong
configuration property.- Returns:
- a
Long
configuration property ordefaultValue
if a property withname
has not been configured - Throws:
ConfigurationException
- if the property is not a valid scalar long
-
getDouble
Returns aDouble
configuration property.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException
- if the property is not a valid scalar double
-
getDouble
Returns aDouble
configuration property.- Returns:
- a
Double
configuration property ordefaultValue
if a property withname
has not been configured - Throws:
ConfigurationException
- if the property is not a valid scalar double
-
getScalarList
Returns aList
configuration property. Empty values and values which do not map to thescalarType
will be removed.- Parameters:
name
- the property namescalarType
- the scalar type, one ofString
,Boolean
,Long
orDouble
- Returns:
- a
List
configuration property, or null if the property has not been configured - Throws:
ConfigurationException
- if the property is not a valid sequence of scalars, or ifscalarType
is not supported
-
getScalarList
Returns aList
configuration property. Entries which are not strings are converted to their string representation.- Returns:
- a
List
configuration property ordefaultValue
if a property withname
has not been configured - Throws:
ConfigurationException
- if the property is not a valid sequence of scalars- See Also:
-
getStructured
Returns aStructuredConfigProperties
configuration property.- Returns:
- a map-valued configuration property, or
null
ifname
has not been configured - Throws:
ConfigurationException
- if the property is not a mapping
-
getStructured
default StructuredConfigProperties getStructured(String name, StructuredConfigProperties defaultValue) Returns aStructuredConfigProperties
configuration property.- Returns:
- a map-valued configuration property, or
defaultValue
ifname
has not been configured - Throws:
ConfigurationException
- if the property is not a mapping
-
getStructuredList
Returns a list ofStructuredConfigProperties
configuration property.- Returns:
- a list of map-valued configuration property, or
null
ifname
has not been configured - Throws:
ConfigurationException
- if the property is not a sequence of mappings
-
getStructuredList
default List<StructuredConfigProperties> getStructuredList(String name, List<StructuredConfigProperties> defaultValue) Returns a list ofStructuredConfigProperties
configuration property.- Returns:
- a list of map-valued configuration property, or
defaultValue
ifname
has not been configured - Throws:
ConfigurationException
- if the property is not a sequence of mappings
-
getPropertyKeys
Returns a set of all configuration property keys.- Returns:
- the configuration property keys
-