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 StructuredConfigPropertiesempty()Return an emptyStructuredConfigPropertiesinstance.getBoolean(String name) Returns aBooleanconfiguration property.default booleangetBoolean(String name, boolean defaultValue) Returns aBooleanconfiguration property.Returns aDoubleconfiguration property.default doubleReturns aDoubleconfiguration property.Returns aIntegerconfiguration property.default intReturns aIntegerconfiguration property.Returns aLongconfiguration property.default longReturns aLongconfiguration property.Returns a set of all configuration property keys.<T> List<T> getScalarList(String name, Class<T> scalarType) Returns aListconfiguration property.default <T> List<T> getScalarList(String name, Class<T> scalarType, List<T> defaultValue) Returns aListconfiguration property.Returns aStringconfiguration property.default StringReturns aStringconfiguration property.getStructured(String name) Returns aStructuredConfigPropertiesconfiguration property.default StructuredConfigPropertiesgetStructured(String name, StructuredConfigProperties defaultValue) Returns aStructuredConfigPropertiesconfiguration property.getStructuredList(String name) Returns a list ofStructuredConfigPropertiesconfiguration property.default List<StructuredConfigProperties> getStructuredList(String name, List<StructuredConfigProperties> defaultValue) Returns a list ofStructuredConfigPropertiesconfiguration property.
-
Method Details
-
empty
Return an emptyStructuredConfigPropertiesinstance.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 aStringconfiguration property.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException- if the property is not a valid scalar string
-
getString
-
getBoolean
Returns aBooleanconfiguration 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 aBooleanconfiguration property.- Returns:
- a
Booleanconfiguration property ordefaultValueif a property withnamehas not been configured - Throws:
ConfigurationException- if the property is not a valid scalar boolean
-
getInt
Returns aIntegerconfiguration property.If the underlying config property is
Long, it is converted toIntegerwithLong.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 aIntegerconfiguration property.If the underlying config property is
Long, it is converted toIntegerwithLong.intValue()which may result in loss of precision.- Returns:
- a
Integerconfiguration property ordefaultValueif a property withnamehas not been configured - Throws:
ConfigurationException- if the property is not a valid scalar integer
-
getLong
Returns aLongconfiguration property.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException- if the property is not a valid scalar long
-
getLong
Returns aLongconfiguration property.- Returns:
- a
Longconfiguration property ordefaultValueif a property withnamehas not been configured - Throws:
ConfigurationException- if the property is not a valid scalar long
-
getDouble
Returns aDoubleconfiguration property.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException- if the property is not a valid scalar double
-
getDouble
Returns aDoubleconfiguration property.- Returns:
- a
Doubleconfiguration property ordefaultValueif a property withnamehas not been configured - Throws:
ConfigurationException- if the property is not a valid scalar double
-
getScalarList
Returns aListconfiguration property. Empty values and values which do not map to thescalarTypewill be removed.- Parameters:
name- the property namescalarType- the scalar type, one ofString,Boolean,LongorDouble- Returns:
- a
Listconfiguration property, or null if the property has not been configured - Throws:
ConfigurationException- if the property is not a valid sequence of scalars, or ifscalarTypeis not supported
-
getScalarList
Returns aListconfiguration property. Entries which are not strings are converted to their string representation.- Returns:
- a
Listconfiguration property ordefaultValueif a property withnamehas not been configured - Throws:
ConfigurationException- if the property is not a valid sequence of scalars- See Also:
-
getStructured
Returns aStructuredConfigPropertiesconfiguration property.- Returns:
- a map-valued configuration property, or
nullifnamehas not been configured - Throws:
ConfigurationException- if the property is not a mapping
-
getStructured
default StructuredConfigProperties getStructured(String name, StructuredConfigProperties defaultValue) Returns aStructuredConfigPropertiesconfiguration property.- Returns:
- a map-valued configuration property, or
defaultValueifnamehas not been configured - Throws:
ConfigurationException- if the property is not a mapping
-
getStructuredList
Returns a list ofStructuredConfigPropertiesconfiguration property.- Returns:
- a list of map-valued configuration property, or
nullifnamehas 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 ofStructuredConfigPropertiesconfiguration property.- Returns:
- a list of map-valued configuration property, or
defaultValueifnamehas not been configured - Throws:
ConfigurationException- if the property is not a sequence of mappings
-
getPropertyKeys
-