Class TestConfigFactory.ConfigDelegate

java.lang.Object
io.helidon.data.sql.testing.TestConfigFactory.ConfigDelegate
All Implemented Interfaces:
Config
Enclosing class:
TestConfigFactory

public static class TestConfigFactory.ConfigDelegate extends Object implements Config
Helidon config delegate for Config in TestConfigFactory.
  • Method Details

    • config

      public void config(Config config)
      Parameters:
      config - the Config insgtance
    • key

      public Config.Key key()
      Description copied from interface: Config
      Returns the fully-qualified key of the Config node.

      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). See Config.name() for more information on the format of each token.

      Specified by:
      key in interface Config
      Returns:
      current config node key
      See Also:
    • get

      public Config get(String s) throws ConfigException
      Description copied from interface: Config
      Returns the single sub-node for the specified sub-key.

      The format of the key is described on Config.key() method.

      Specified by:
      get in interface Config
      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

      public Config root()
      Description copied from interface: Config
      Get the root of the configuration tree. In case this node is part of detached tree, this method returns the node that was detached.
      Specified by:
      root in interface Config
      Returns:
      root of this configuration tree
    • detach

      public Config detach() throws ConfigException
      Description copied from interface: Config
      Returns a copy of the Config node 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 = WARNING
       
      The Config instances name1 and name2 represents 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 node
       
      The 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:
      detach in interface Config
      Returns:
      returns detached Config instance of same config node
      Throws:
      ConfigException - if not defined
    • exists

      public boolean exists()
      Description copied from interface: Config
      Returns true if the node exists, whether an object, a list, a value node, etc.
      Specified by:
      exists in interface Config
      Returns:
      true if the node exists
    • traverse

      public Stream<? extends Config> traverse()
      Description copied from interface: Config
      Iterative deepening depth-first traversal of the node and its subtree as a Stream<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.

      Specified by:
      traverse in interface Config
      Returns:
      stream of deepening depth-first sub-nodes
    • isLeaf

      public boolean isLeaf()
      Description copied from interface: Config
      Returns true if this node exists and is a leaf node (has no children).

      A leaf node has no nested configuration subtree and has a single value.

      Specified by:
      isLeaf in interface Config
      Returns:
      true if the node is existing leaf node, false otherwise.
    • isObject

      public boolean isObject()
      Description copied from interface: Config
      Returns true if this node exists and is Type#Object.
      Specified by:
      isObject in interface Config
      Returns:
      true if the node exists and is Type#Object, false otherwise.
    • isList

      public boolean isList()
      Description copied from interface: Config
      Returns true if this node exists and is Type#List.
      Specified by:
      isList in interface Config
      Returns:
      true if the node exists and is Type#List, false otherwise.
    • hasValue

      public boolean hasValue()
      Description copied from interface: Config
      Returns true if 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.

      Specified by:
      hasValue in interface Config
      Returns:
      true if the node has direct value, false otherwise.
    • as

      public <T> ConfigValue<T> as(Class<T> aClass)
      Description copied from interface: Config
      Typed value as a ConfigValue.
      Specified by:
      as in interface Config
      Type Parameters:
      T - type
      Parameters:
      aClass - type class
      Returns:
      typed value
      See Also:
    • map

      public <T> ConfigValue<T> map(Function<Config,T> function)
      Description copied from interface: Config
      Typed value as a ConfigValue created from factory method. To convert from String, you can use config.asString().as(Function).
      Specified by:
      map in interface Config
      Type Parameters:
      T - type
      Parameters:
      function - method to create an instance from config
      Returns:
      typed value
    • asList

      public <T> ConfigValue<List<T>> asList(Class<T> aClass) throws ConfigException
      Description copied from interface: Config
      Returns list of specified type.
      Specified by:
      asList in interface Config
      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

      public <T> ConfigValue<List<T>> mapList(Function<Config,T> function) throws ConfigException
      Description copied from interface: Config
      Returns this node as a list mapping each list value using the provided mapper.
      Specified by:
      mapList in interface Config
      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

      public <C extends Config> ConfigValue<List<C>> asNodeList() throws ConfigException
      Description copied from interface: Config
      Returns a list of child Config nodes if the node is Type#OBJECT. Returns a list of element nodes if the node is Type#LIST. Throws MissingValueException if the node is Type#MISSING. Otherwise, if node is Type#VALUE, it throws ConfigMappingException.
      Specified by:
      asNodeList in interface Config
      Type Parameters:
      C - the common config derived type
      Returns:
      a list of Type#OBJECT members or a list of Type#LIST members
      Throws:
      ConfigException - in case the node is Type#VALUE
    • asMap

      public ConfigValue<Map<String,String>> asMap() throws ConfigException
      Description copied from interface: Config
      Transform all leaf nodes (values) into Map instance.
      Specified by:
      asMap in interface Config
      Returns:
      new Map instance that contains all config leaf node values
      Throws:
      ConfigException - in case the node is Type#MISSING.