Interface ConfigProperties
-
- All Known Subinterfaces:
MutableConfigProperties
- All Known Implementing Classes:
EmptyConfigProperties,MutableConfigPropertiesImpl,SimpleConfigProperties
public interface ConfigPropertiesSimple abstraction interface for generic access to configuration properties (from spring-bootapplication.properties).- Since:
- 3.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static ConfigPropertiesEMPTYAn immutable instance ofConfigPropertiesthat is alwaysemptystatic charKEY_SEPARATORThe separator charactor '.' for hierarchical keys such as "spring.datasource.url".
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ConfigPropertiesgetChild(String key)ConfigPropertiesgetChild(String... keys)Set<String>getChildKeys()StringgetChildValue(String key)Shortcut forgetChild(key).getValue().StringgetChildValue(String... keys)Shortcut forgetChild(keys).getValue().StringgetValue()<T> TgetValue(Class<T> type)<T> TgetValue(Class<T> type, T defaultValue)booleangetValueAsBoolean()MutableConfigPropertiesinherit(ConfigProperties parent)booleanisEmpty()Map<String,String>toFlatMap()Map<String,String>toFlatMap(String rootKey)Map<String,Object>toHierarchicalMap()
-
-
-
Field Detail
-
KEY_SEPARATOR
static final char KEY_SEPARATOR
The separator charactor '.' for hierarchical keys such as "spring.datasource.url".- See Also:
- Constant Field Values
-
EMPTY
static final ConfigProperties EMPTY
An immutable instance ofConfigPropertiesthat is alwaysempty
-
-
Method Detail
-
getChildKeys
Set<String> getChildKeys()
- Returns:
- the
Setof thedirect child keysavailable in theConfigProperties-node.
-
getChild
ConfigProperties getChild(String key)
- Parameters:
key- thechild keyof the requested configuration value.- Returns:
- the child
ConfigProperties. Will be anemptychild if undefined.
-
getChild
ConfigProperties getChild(String... keys)
Recursive variant ofgetChild(String)such thatis the same asconfig.getChild(key1, ..., keyN).config.getChild(key1)...getChild(keyN)- Parameters:
keys- the keys to traverse recursively.- Returns:
- the descendant
childreached from recursively traversing the givenkeys.
-
getChildValue
String getChildValue(String key)
Shortcut forgetChild(key).getValue().- Parameters:
key- thekey of the child- Returns:
- the value of this
ConfigProperties-node. May benull.
-
getChildValue
String getChildValue(String... keys)
Shortcut forgetChild(keys).getValue().- Parameters:
keys- the keys to traverse recursively.- Returns:
- the
valueof thedescendant childtraversed bykeys. May benull.
-
getValue
String getValue()
- Returns:
- the value of this
ConfigProperties-node. May benull.
-
getValue
<T> T getValue(Class<T> type)
- Type Parameters:
T- the requestedtype- Parameters:
type- theClassreflecting the requested result type.- Returns:
- the value of this
ConfigProperties-node converted to the giventype. Will benullif undefined.
-
getValue
<T> T getValue(Class<T> type, T defaultValue)
- Type Parameters:
T- the requestedtype- Parameters:
type- theClassreflecting the requested result type.defaultValue- the value returned as default if the actualvalueis undefined.- Returns:
- the value of this
ConfigProperties-node converted to the giventype. Will bedefaultValueif undefined.
-
getValueAsBoolean
boolean getValueAsBoolean()
- Returns:
- the
getValue(Class, Object)asbooleanwithfalseas default.
-
isEmpty
boolean isEmpty()
- Returns:
trueif this is an emptyConfigProperties-node that neither has avaluenoranychild.
-
toHierarchicalMap
Map<String,Object> toHierarchicalMap()
- Returns:
- this
ConfigPropertiesconverted to ahierarchicalMap.
-
inherit
MutableConfigProperties inherit(ConfigProperties parent)
- Parameters:
parent- the parentConfigPropertiesto extend.- Returns:
- a new instance of
ConfigPropertieswith allchildrenandvalue(s) from thisConfigProperties-tree and allchildrenandvalue(s) inherited from the givenparentConfigProperties-tree if they are undefined in this tree.
-
-