Interface DeclarativeConfigProperties
An instance of DeclarativeConfigProperties 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 DeclarativeConfigPropertiesempty()Return an emptyDeclarativeConfigPropertiesinstance.getBoolean(String name) Returns aBooleanconfiguration property.default booleangetBoolean(String name, boolean defaultValue) Returns aBooleanconfiguration property.io.opentelemetry.common.ComponentLoaderReturn aComponentLoaderthat should be used to load SPIs.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 aDeclarativeConfigPropertiesconfiguration property.default DeclarativeConfigPropertiesgetStructured(String name, DeclarativeConfigProperties defaultValue) Returns a list ofDeclarativeConfigPropertiesconfiguration property.getStructuredList(String name) Returns a list ofDeclarativeConfigPropertiesconfiguration property.default List<DeclarativeConfigProperties> getStructuredList(String name, List<DeclarativeConfigProperties> defaultValue) Returns a list ofDeclarativeConfigPropertiesconfiguration property.toMap(DeclarativeConfigProperties declarativeConfigProperties) Return a map representation of thedeclarativeConfigProperties.
-
Method Details
-
empty
Return an emptyDeclarativeConfigPropertiesinstance.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"). -
toMap
Return a map representation of thedeclarativeConfigProperties. -
getString
Returns aStringconfiguration property.- Returns:
- null if the property has not been configured
- Throws:
DeclarativeConfigException- if the property is not a valid scalar string
-
getString
Returns aStringconfiguration property.- Returns:
- a
Stringconfiguration property ordefaultValueif a property withnamehas not been configured - Throws:
DeclarativeConfigException- if the property is not a valid scalar string
-
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:
DeclarativeConfigException- 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:
DeclarativeConfigException- 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:
DeclarativeConfigException- 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:
DeclarativeConfigException- if the property is not a valid scalar integer
-
getLong
Returns aLongconfiguration property.- Returns:
- null if the property has not been configured
- Throws:
DeclarativeConfigException- 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:
DeclarativeConfigException- if the property is not a valid scalar long
-
getDouble
Returns aDoubleconfiguration property.- Returns:
- null if the property has not been configured
- Throws:
DeclarativeConfigException- 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:
DeclarativeConfigException- 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:
DeclarativeConfigException- 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. -
getStructured
Returns aDeclarativeConfigPropertiesconfiguration property.- Returns:
- a map-valued configuration property, or
nullifnamehas not been configured - Throws:
DeclarativeConfigException- if the property is not a mapping
-
getStructured
default DeclarativeConfigProperties getStructured(String name, DeclarativeConfigProperties defaultValue) Returns a list ofDeclarativeConfigPropertiesconfiguration property.- Returns:
- a map-valued configuration property, or
defaultValueifnamehas not been configured - Throws:
DeclarativeConfigException- if the property is not a mapping
-
getStructuredList
Returns a list ofDeclarativeConfigPropertiesconfiguration property.- Returns:
- a list of map-valued configuration property, or
nullifnamehas not been configured - Throws:
DeclarativeConfigException- if the property is not a sequence of mappings
-
getStructuredList
default List<DeclarativeConfigProperties> getStructuredList(String name, List<DeclarativeConfigProperties> defaultValue) Returns a list ofDeclarativeConfigPropertiesconfiguration property.- Returns:
- a list of map-valued configuration property, or
defaultValueifnamehas not been configured - Throws:
DeclarativeConfigException- if the property is not a sequence of mappings
-
getPropertyKeys
Returns a set of all configuration property keys.- Returns:
- the configuration property keys
-
getComponentLoader
io.opentelemetry.common.ComponentLoader getComponentLoader()Return aComponentLoaderthat should be used to load SPIs.
-