Interface StructuredConfigProperties
-
- All Known Implementing Classes:
EmptyStructuredConfigProperties
public interface StructuredConfigPropertiesAn interface for accessing structured configuration data.An instance of
StructuredConfigPropertiesis equivalent to a YAML mapping node. It has accessors for reading scalar properties,getStructured(String)for reading children which are themselves mappings, andgetStructuredList(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
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static StructuredConfigPropertiesempty()Return an emptyStructuredConfigPropertiesinstance.java.lang.BooleangetBoolean(java.lang.String name)Returns aBooleanconfiguration property.default booleangetBoolean(java.lang.String name, boolean defaultValue)Returns aBooleanconfiguration property.java.lang.DoublegetDouble(java.lang.String name)Returns aDoubleconfiguration property.default doublegetDouble(java.lang.String name, double defaultValue)Returns aDoubleconfiguration property.java.lang.IntegergetInt(java.lang.String name)Returns aIntegerconfiguration property.default intgetInt(java.lang.String name, int defaultValue)Returns aIntegerconfiguration property.java.lang.LonggetLong(java.lang.String name)Returns aLongconfiguration property.default longgetLong(java.lang.String name, long defaultValue)Returns aLongconfiguration property.java.util.Set<java.lang.String>getPropertyKeys()Returns a set of all configuration property keys.<T> java.util.List<T>getScalarList(java.lang.String name, java.lang.Class<T> scalarType)Returns aListconfiguration property.default <T> java.util.List<T>getScalarList(java.lang.String name, java.lang.Class<T> scalarType, java.util.List<T> defaultValue)Returns aListconfiguration property.java.lang.StringgetString(java.lang.String name)Returns aStringconfiguration property.default java.lang.StringgetString(java.lang.String name, java.lang.String defaultValue)Returns aStringconfiguration property.StructuredConfigPropertiesgetStructured(java.lang.String name)Returns aStructuredConfigPropertiesconfiguration property.default StructuredConfigPropertiesgetStructured(java.lang.String name, StructuredConfigProperties defaultValue)Returns aStructuredConfigPropertiesconfiguration property.java.util.List<StructuredConfigProperties>getStructuredList(java.lang.String name)Returns a list ofStructuredConfigPropertiesconfiguration property.default java.util.List<StructuredConfigProperties>getStructuredList(java.lang.String name, java.util.List<StructuredConfigProperties> defaultValue)Returns a list ofStructuredConfigPropertiesconfiguration property.
-
-
-
Method Detail
-
empty
static StructuredConfigProperties 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
@Nullable java.lang.String getString(java.lang.String name)
Returns aStringconfiguration property.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException- if the property is not a valid scalar string
-
getString
default java.lang.String getString(java.lang.String name, java.lang.String defaultValue)Returns aStringconfiguration property.- Returns:
- a
Stringconfiguration property ordefaultValueif a property withnamehas not been configured - Throws:
ConfigurationException- if the property is not a valid scalar string
-
getBoolean
@Nullable java.lang.Boolean getBoolean(java.lang.String name)
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
default boolean getBoolean(java.lang.String name, boolean defaultValue)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
@Nullable java.lang.Integer getInt(java.lang.String name)
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
default int getInt(java.lang.String name, int defaultValue)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
@Nullable java.lang.Long getLong(java.lang.String name)
Returns aLongconfiguration property.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException- if the property is not a valid scalar long
-
getLong
default long getLong(java.lang.String name, long defaultValue)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
@Nullable java.lang.Double getDouble(java.lang.String name)
Returns aDoubleconfiguration property.- Returns:
- null if the property has not been configured
- Throws:
ConfigurationException- if the property is not a valid scalar double
-
getDouble
default double getDouble(java.lang.String name, double defaultValue)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
@Nullable <T> java.util.List<T> getScalarList(java.lang.String name, java.lang.Class<T> scalarType)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
default <T> java.util.List<T> getScalarList(java.lang.String name, java.lang.Class<T> scalarType, java.util.List<T> defaultValue)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:
ConfigProperties.getList(String name)
-
getStructured
@Nullable StructuredConfigProperties getStructured(java.lang.String name)
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(java.lang.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
@Nullable java.util.List<StructuredConfigProperties> getStructuredList(java.lang.String name)
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 java.util.List<StructuredConfigProperties> getStructuredList(java.lang.String name, java.util.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
java.util.Set<java.lang.String> getPropertyKeys()
Returns a set of all configuration property keys.- Returns:
- the configuration property keys
-
-