Class PropertyTree


  • public class PropertyTree
    extends Object
    A tree representation for dot-separated properties. The tree consists of nodes, where each node can have a value. Each node can have an arbitrary number of child nodes which are addressed by the node name.
    • Method Detail

      • getRequiredString

        public String getRequiredString​(String... path)
        Get the value at the given path. The node is required to exist.
        Parameters:
        path - the path of the node to return split into its elements
        Returns:
        the value of the node at the given path
        Throws:
        NoSuchElementException - if there is no such node or the node has no value
      • getOptionalInteger

        public Optional<Integer> getOptionalInteger​(String... path)
        Get the value at the given path parsed as an Integer.
        Parameters:
        path - the path of the node to return split into its elements
        Returns:
        the Integer value of the node at the given path or Optional.empty() if one of the nodes in the path does not exist
      • getOptionalBoolean

        public Optional<Boolean> getOptionalBoolean​(String... path)
        Get the value at the given path parsed as an Boolean.
        Parameters:
        path - the path of the node to return split into its elements
        Returns:
        the Integer value of the node at the given path or Optional.empty() if one of the nodes in the path does not exist
      • getMap

        public Map<String,​String> getMap​(String... path)
        Get the values of all children nodes at the given path. The values are mapped by the children node names.
        Parameters:
        path - the path of the node to return split into its elements
        Returns:
        the Map from the children node names to its values. If one of the nodes in the path does not exist this will return an empty Map
      • getFlatMap

        public Map<String,​String> getFlatMap​(String... path)
        Get the values of all child nodes at the given path, enumerating any subtrees and converting their paths into dot-separated property names. This is intended to handle parameter keys containing dots - see NMS-12738.
        Parameters:
        path - the path of the node to return split into its elements
        Returns:
        the Map from the children node names to its values. If one of the nodes in the path does not exist this will return an empty Map
      • getSubTrees

        public Map<String,​PropertyTree> getSubTrees​(String... path)
        Get the children nodes at the given path represented as sub-trees. The sub-trees are mapped by the children node names. The resulting Map will contain an entry for each children of the addressed node. The name of the children will be used as key. The value will be new PropertyTree instance in which the children node is used as root node.
        Parameters:
        path - the path of the node to return split into its elements
        Returns:
        the Map from the children node names to its representations as sub-trees. If one of the nodes in the path does not exist this will return an empty Map
      • from

        public static PropertyTree from​(Map<String,​String> map)
        Create a new PropertyTree from the given Map. The keys of the map are handled as full-qualified dot-separated paths.
        Parameters:
        map - the path / value mapping used to create the property tree
        Returns:
        a new PropertyTree instance
      • from

        public static PropertyTree from​(Dictionary<String,​?> properties)
        Create a new PropertyTree from the given Dictionary. The keys of the properties are handled as full-qualified dot-separated paths.
        Parameters:
        properties - the path / value mapping used to create the property tree
        Returns:
        a new PropertyTree instance