Interface ConfigProperties
-
- All Known Subinterfaces:
MutableConfigProperties
- All Known Implementing Classes:
SimpleConfigProperties
public interface ConfigProperties
Simple 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 ConfigProperties
EMPTY
An immutable instance ofConfigProperties
that is alwaysempty
static char
KEY_SEPARATOR
The separator charactor '.' for hierarchical keys such as "spring.datasource.url".
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ConfigProperties
getChild(String key)
ConfigProperties
getChild(String... keys)
Set<String>
getChildKeys()
String
getChildValue(String key)
Shortcut forgetChild(key)
.getValue()
.String
getChildValue(String... keys)
Shortcut forgetChild(keys)
.getValue()
.String
getValue()
<T> T
getValue(Class<T> type)
<T> T
getValue(Class<T> type, T defaultValue)
boolean
getValueAsBoolean()
MutableConfigProperties
inherit(ConfigProperties parent)
boolean
isEmpty()
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 ofConfigProperties
that is alwaysempty
-
-
Method Detail
-
getChildKeys
Set<String> getChildKeys()
- Returns:
- the
Set
of thedirect child keys
available in theConfigProperties
-node.
-
getChild
ConfigProperties getChild(String key)
- Parameters:
key
- thechild key
of the requested configuration value.- Returns:
- the child
ConfigProperties
. Will be anempty
child if undefined.
-
getChild
ConfigProperties getChild(String... keys)
Recursive variant ofgetChild(String)
such that
is the same asconfig
.getChild
(key1, ..., keyN)
.config
.getChild
(key1)...getChild
(keyN)- Parameters:
keys
- the keys to traverse recursively.- Returns:
- the descendant
child
reached 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
value
of thedescendant child
traversed 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
- theClass
reflecting the requested result type.- Returns:
- the value of this
ConfigProperties
-node converted to the giventype
. Will benull
if undefined.
-
getValue
<T> T getValue(Class<T> type, T defaultValue)
- Type Parameters:
T
- the requestedtype
- Parameters:
type
- theClass
reflecting the requested result type.defaultValue
- the value returned as default if the actualvalue
is undefined.- Returns:
- the value of this
ConfigProperties
-node converted to the giventype
. Will bedefaultValue
if undefined.
-
getValueAsBoolean
boolean getValueAsBoolean()
- Returns:
- the
getValue(Class, Object)
asboolean
withfalse
as default.
-
isEmpty
boolean isEmpty()
- Returns:
true
if this is an emptyConfigProperties
-node that neither has avalue
norany
child
.
-
toHierarchicalMap
Map<String,Object> toHierarchicalMap()
- Returns:
- this
ConfigProperties
converted to ahierarchical
Map
.
-
inherit
MutableConfigProperties inherit(ConfigProperties parent)
- Parameters:
parent
- the parentConfigProperties
to extend.- Returns:
- a new instance of
ConfigProperties
with allchildren
andvalue
(s) from thisConfigProperties
-tree and allchildren
andvalue
(s) inherited from the givenparent
ConfigProperties
-tree if they are undefined in this tree.
-
-