Class TestConfigFactory.ConfigDelegate
- All Implemented Interfaces:
Config
- Enclosing class:
TestConfigFactory
Config in TestConfigFactory.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.helidon.common.config.Config
Config.Key -
Method Summary
Modifier and TypeMethodDescription<T> ConfigValue<T> Typed value as aConfigValue.<T> ConfigValue<List<T>> Returns list of specified type.asMap()Transform all leaf nodes (values) into Map instance.<C extends Config>
ConfigValue<List<C>> Returns a list of childConfignodes if the node isType#OBJECT.voidReturnsConfigfromTestConfigFactory.detach()Returns a copy of theConfignode with no parent.booleanexists()Returnstrueif the node exists, whether an object, a list, a value node, etc.Returns the single sub-node for the specified sub-key.booleanhasValue()Returnstrueif this configuration node has a direct value.booleanisLeaf()Returnstrueif this node exists and is a leaf node (has no children).booleanisList()Returnstrueif this node exists and is Type#List.booleanisObject()Returnstrueif this node exists and is Type#Object.key()Returns the fully-qualified key of theConfignode.<T> ConfigValue<T> Typed value as aConfigValuecreated from factory method.<T> ConfigValue<List<T>> Returns this node as a list mapping each list value using the provided mapper.root()Get the root of the configuration tree.traverse()Iterative deepening depth-first traversal of the node and its subtree as aStream<Config>.
-
Method Details
-
config
ReturnsConfigfromTestConfigFactory.- Parameters:
config- theConfiginsgtance
-
key
Description copied from interface:ConfigReturns the fully-qualified key of theConfignode.The fully-qualified key is a sequence of tokens derived from the name of each node along the path from the config root to the current node. Tokens are separated by
.(the dot character). SeeConfig.name()for more information on the format of each token. -
get
Description copied from interface:ConfigReturns the single sub-node for the specified sub-key.The format of the key is described on
Config.key()method.- Specified by:
getin interfaceConfig- Parameters:
s- sub-key of requested sub-node- Returns:
- config node for specified sub-key, never returns
null. - Throws:
ConfigException- if not defined- See Also:
-
root
Description copied from interface:ConfigGet the root of the configuration tree. In case this node is part ofdetachedtree, this method returns the node that was detached. -
detach
Description copied from interface:ConfigReturns a copy of theConfignode with no parent.The returned node acts as a root node for the subtree below it. Its key is the empty string;
"". The original config node is unchanged, and the original and the copy point to the same children.Consider the following configuration:
app: name: Example 1 page-size: 20 logging: app.level = INFO level = WARNINGTheConfiginstancesname1andname2represents same data and in fact refer to the same object:Config name1 = config .get("app") .get("name"); Config name2 = config .get("app") .detach() //DETACHED node .get("name"); assert name1.asString() == "Example 1"; assert name2.asString() == "Example 1"; //DETACHED nodeThe only difference is the key each node returns:assert name1.key() == "app.name"; assert name2.key() == "name"; //DETACHED node
See asMap() for example of config detaching.
- Specified by:
detachin interfaceConfig- Returns:
- returns detached Config instance of same config node
- Throws:
ConfigException- if not defined
-
exists
public boolean exists()Description copied from interface:ConfigReturnstrueif the node exists, whether an object, a list, a value node, etc. -
traverse
Description copied from interface:ConfigIterative deepening depth-first traversal of the node and its subtree as aStream<Config>.If the config node does not exist or is a leaf the returned stream is empty.
Depending on the structure of the configuration the returned stream can deliver a mix of object, list, and leaf value nodes. The stream will include and traverse through object members and list elements.
-
isLeaf
public boolean isLeaf()Description copied from interface:ConfigReturnstrueif this node exists and is a leaf node (has no children).A leaf node has no nested configuration subtree and has a single value.
-
isObject
public boolean isObject()Description copied from interface:ConfigReturnstrueif this node exists and is Type#Object. -
isList
public boolean isList()Description copied from interface:ConfigReturnstrueif this node exists and is Type#List. -
hasValue
public boolean hasValue()Description copied from interface:ConfigReturnstrueif this configuration node has a direct value.This may be a value node (e.g. a leaf) or object node or a list node (e.g. a branch with value). The application can invoke methods such as
Config.as(Class)on nodes that have value. -
as
Description copied from interface:ConfigTyped value as aConfigValue. -
map
Description copied from interface:ConfigTyped value as aConfigValuecreated from factory method. To convert from String, you can useconfig.asString().as(Function). -
asList
Description copied from interface:ConfigReturns list of specified type.- Specified by:
asListin interfaceConfig- Type Parameters:
T- type of list elements- Parameters:
aClass- type class- Returns:
- a typed list with values
- Throws:
ConfigException- in case of problem to map property value.
-
mapList
Description copied from interface:ConfigReturns this node as a list mapping each list value using the provided mapper.- Specified by:
mapListin interfaceConfig- Type Parameters:
T- type of list elements- Parameters:
function- mapper to convert each list node into a typed value- Returns:
- a typed list with values
- Throws:
ConfigException- in case the mapper fails to map the values
-
asNodeList
Description copied from interface:ConfigReturns a list of childConfignodes if the node isType#OBJECT. Returns a list of element nodes if the node isType#LIST. ThrowsMissingValueExceptionif the node isType#MISSING. Otherwise, if node isType#VALUE, it throwsConfigMappingException.- Specified by:
asNodeListin interfaceConfig- Type Parameters:
C- the common config derived type- Returns:
- a list of
Type#OBJECTmembers or a list ofType#LISTmembers - Throws:
ConfigException- in case the node isType#VALUE
-
asMap
Description copied from interface:ConfigTransform all leaf nodes (values) into Map instance.- Specified by:
asMapin interfaceConfig- Returns:
- new Map instance that contains all config leaf node values
- Throws:
ConfigException- in case the node is Type#MISSING.
-