Interface TreeNode<Self extends TreeNode<? extends Self>>
- 
- All Known Implementing Classes:
- DefaultTreeNode,- ModelCriteriaNode,- TreeStorageNodeInstance,- TreeStorageNodePrescription
 
 public interface TreeNode<Self extends TreeNode<? extends Self>>Interface representing a node in a tree that has ID.Think twice when adding a method here: if added method does not operate purely on nodes or a generic tree, it does not belong here. - Author:
- hmlnarik
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Interface Description static classTreeNode.PathOrientation
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddChild(int index, Self node)Adds a node as a child of this node, and sets the parent of thenodeto this node.voidaddChild(Self node)Adds a node as a child of this node, and sets the parent of thenodeto this node.Optional<Self>findFirstBfs(Predicate<Self> visitor)Breadth-first search for a node.Optional<Self>findFirstBottommostDfs(Predicate<Self> visitor)Depth-first search for a node that is bottommost from those matching DFS.Optional<Self>findFirstDfs(Predicate<Self> visitor)Depth-first search for a node.voidforEachParent(Consumer<Self> visitor)Calls the givenvisitoron each node laying on the path from this node (exclusive) to the root of the tree (inclusive).Optional<Self>getChild(String id)Returns a node by ID.List<Self>getChildren()Returns the children of the current node.Map<String,Object>getEdgeProperties()Parent-to-this-node edge properties.<V> Optional<V>getEdgeProperty(String key, Class<V> clazz)Convenience method for obtaining a single parent-to-this-node edge property.StringgetId()Returns ID of the node, which could match e.g.Map<String,Object>getNodeProperties()Properties of the this node.<V> Optional<V>getNodeProperty(String key, Class<V> clazz)Convenience method for obtaining a single property of this node.Optional<Self>getParent()Returns parent node or an emptyOptionalif this node is a root node.Stream<Self>getParentsStream()Returns a stream of the nodes laying on the path from this node (exclusive) to the root of the tree (inclusive).List<Self>getPathToRoot(TreeNode.PathOrientation orientation)Returns the path (list of nodes) from this node to root node.Map<String,Object>getTreeProperties()Properties of the whole tree.<V> Optional<V>getTreeProperty(String key, Class<V> clazz)Convenience method for obtaining a single property of tree that this node belongs to.intremoveChild(Predicate<Self> shouldRemove)Removes child nodes satisfying the given predicate.Optional<Self>removeChild(Self node)Removes the given child node.voidsetParent(Self parent)Sets the parent node to the givenparent.voidwalkBfs(Consumer<Self> visitor)Walks the tree with the given visitor in breadth-first search manner.voidwalkDfs(Consumer<Self> visitorUponEntry, Consumer<Self> visitorAfterChildrenVisited)Walks the tree with the given visitor in depth-first search manner.
 
- 
- 
- 
Method Detail- 
addChildvoid addChild(Self node) Adds a node as a child of this node, and sets the parent of thenodeto this node.- Parameters:
- node- Future child node. If- nullor the node is already amongst the children list, no action is done.
 
 - 
addChildvoid addChild(int index, Self node)Adds a node as a child of this node, and sets the parent of thenodeto this node.- Parameters:
- index- Index at which the specified element is to be inserted
- node- Future child node. If- nullor the node is already amongst the children list, no action is done.
 
 - 
getChildOptional<Self> getChild(String id) Returns a node by ID. If there are more nodes with the same ID, any node from those may be returned.- Parameters:
- id-
- Returns:
 
 - 
getChildrenList<Self> getChildren() Returns the children of the current node. Order does matter.- Returns:
- Read-only list of the children. Never returns null.
 
 - 
getEdgePropertiesMap<String,Object> getEdgeProperties() Parent-to-this-node edge properties. For example, import/no-import mode or sync mode belongs here.- Returns:
- Returns properties of the edge from the parent to this node. Never returns null.
 
 - 
getEdgeProperty<V> Optional<V> getEdgeProperty(String key, Class<V> clazz) Convenience method for obtaining a single parent-to-this-node edge property.- Type Parameters:
- V-
- Parameters:
- key-
- clazz-
- Returns:
- Optionalwith a property value if it exists. Never returns- null
 
 - 
getIdString getId() Returns ID of the node, which could match e.g. ID of the component with storage definition.- Returns:
- Node ID
 
 - 
getNodePropertiesMap<String,Object> getNodeProperties() Properties of the this node. In storage context, properties of the single map storage represented by this node, for example read-only/read-write flag.- Returns:
- Returns properties of the storage managed in this node. Never returns null.
 
 - 
getNodeProperty<V> Optional<V> getNodeProperty(String key, Class<V> clazz) Convenience method for obtaining a single property of this node.- Type Parameters:
- V-
- Parameters:
- key-
- clazz-
- Returns:
- Optionalwith a property value if it exists. Never returns- null
 
 - 
getTreePropertiesMap<String,Object> getTreeProperties() Properties of the whole tree. For example, kind of the stored objects, e.g. realms or clients.- Returns:
- Returns properties of the tree that contains in this node. Never returns null.
 
 - 
getTreeProperty<V> Optional<V> getTreeProperty(String key, Class<V> clazz) Convenience method for obtaining a single property of tree that this node belongs to.- Type Parameters:
- V-
- Parameters:
- key-
- clazz-
- Returns:
- Optionalwith a property value if it exists. Never returns- null
 
 - 
removeChildOptional<Self> removeChild(Self node) Removes the given child node.- Parameters:
- node- Node to remove
- Returns:
- Removed node
 
 - 
removeChildint removeChild(Predicate<Self> shouldRemove) Removes child nodes satisfying the given predicate.- Parameters:
- node- Predicate on node returning- truefor each node that should be removed
- Returns:
- Number of removed nodes
 
 - 
getParentOptional<Self> getParent() Returns parent node or an emptyOptionalif this node is a root node.- Returns:
- See description. Never returns null.
 
 - 
setParentvoid setParent(Self parent) Sets the parent node to the givenparent. If this node was a child of another node, also removes this node from the children of the previous parent.- Parameters:
- parent- New parent node or- nullif this node should be parentless.
 
 - 
findFirstDfsOptional<Self> findFirstDfs(Predicate<Self> visitor) Depth-first search for a node.- Parameters:
- visitor- Predicate on nodes, returns- truewhen a search condition is satisfied which terminates the search.
- Returns:
- Leftmost first node that matches the predicate, nullwhen no node matches.
 
 - 
findFirstBottommostDfsOptional<Self> findFirstBottommostDfs(Predicate<Self> visitor) Depth-first search for a node that is bottommost from those matching DFS.- Parameters:
- visitor- Predicate on nodes, returns- truewhen a search condition is satisfied which terminates the search.
- Returns:
- Leftmost and bottommost node that matches the predicate, nullwhen no node matches.
 
 - 
findFirstBfsOptional<Self> findFirstBfs(Predicate<Self> visitor) Breadth-first search for a node.- Parameters:
- visitor- Predicate on nodes, returns- truewhen a search condition is satisfied which terminates the search.
- Returns:
- First node that matches the predicate, nullwhen no node matches.
 
 - 
getPathToRootList<Self> getPathToRoot(TreeNode.PathOrientation orientation) Returns the path (list of nodes) from this node to root node.- Parameters:
- orientation- Determines order of the nodes in the returned list - either this node is first and the root node is last, (- TreeNode.PathOrientation.BOTTOM_FIRST) or vice versa (- TreeNode.PathOrientation.TOP_FIRST).
- Returns:
 
 - 
getParentsStreamStream<Self> getParentsStream() Returns a stream of the nodes laying on the path from this node (exclusive) to the root of the tree (inclusive).- Returns:
 
 - 
forEachParentvoid forEachParent(Consumer<Self> visitor) Calls the givenvisitoron each node laying on the path from this node (exclusive) to the root of the tree (inclusive).- Parameters:
- visitor-
 
 - 
walkDfsvoid walkDfs(Consumer<Self> visitorUponEntry, Consumer<Self> visitorAfterChildrenVisited) Walks the tree with the given visitor in depth-first search manner.- Parameters:
- visitorUponEntry- Visitor called upon entry of the node. May be- null, in that case no action is performed.
- visitorAfterChildrenVisited- Visitor called before exit of the node. May be- null, in that case no action is performed.
 
 
- 
 
-