Class DefaultTreeNode<Self extends DefaultTreeNode<Self>>
- java.lang.Object
- 
- org.keycloak.models.map.storage.tree.DefaultTreeNode<Self>
 
- 
- All Implemented Interfaces:
- TreeNode<Self>
 - Direct Known Subclasses:
- ModelCriteriaNode,- TreeStorageNodeInstance,- TreeStorageNodePrescription
 
 public class DefaultTreeNode<Self extends DefaultTreeNode<Self>> extends Object implements TreeNode<Self> Generic implementation of a node in a tree.Any method that is not purely on tree or nodes should go into a specialized subclass of this class! - Author:
- hmlnarik
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.keycloak.models.map.storage.tree.TreeNodeTreeNode.PathOrientation
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected Map<String,Object>edgePropertiesprotected Map<String,Object>nodePropertiesprotected Map<String,Object>treeProperties
 - 
Method SummaryAll Methods Instance Methods Concrete 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.<RNode extends TreeNode<? super RNode>>
 RNodecloneTree(Function<Self,RNode> instantiateFunc)booleanequals(Object obj)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.protected StringgetLabel()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.booleanhasChildren()inthashCode()booleanhasNoChildren()intremoveChild(Predicate<Self> shouldRemove)Removes child nodes satisfying the given predicate.Optional<Self>removeChild(Self node)Removes the given child node.voidsetEdgeProperty(String property, Object value)voidsetId(String id)voidsetNodeProperty(String property, Object value)voidsetParent(Self parent)Sets the parent node to the givenparent.StringtoString()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- 
getEdgePropertiespublic Map<String,Object> getEdgeProperties() Description copied from interface:TreeNodeParent-to-this-node edge properties. For example, import/no-import mode or sync mode belongs here.- Specified by:
- getEdgePropertiesin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- Returns properties of the edge from the parent to this node. Never returns null.
 
 - 
getEdgePropertypublic <V> Optional<V> getEdgeProperty(String key, Class<V> clazz) Description copied from interface:TreeNodeConvenience method for obtaining a single parent-to-this-node edge property.- Specified by:
- getEdgePropertyin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- Optionalwith a property value if it exists. Never returns- null
 
 - 
getNodePropertiespublic Map<String,Object> getNodeProperties() Description copied from interface:TreeNodeProperties of the this node. In storage context, properties of the single map storage represented by this node, for example read-only/read-write flag.- Specified by:
- getNodePropertiesin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- Returns properties of the storage managed in this node. Never returns null.
 
 - 
getNodePropertypublic <V> Optional<V> getNodeProperty(String key, Class<V> clazz) Description copied from interface:TreeNodeConvenience method for obtaining a single property of this node.- Specified by:
- getNodePropertyin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- Optionalwith a property value if it exists. Never returns- null
 
 - 
getTreePropertiespublic Map<String,Object> getTreeProperties() Description copied from interface:TreeNodeProperties of the whole tree. For example, kind of the stored objects, e.g. realms or clients.- Specified by:
- getTreePropertiesin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- Returns properties of the tree that contains in this node. Never returns null.
 
 - 
getTreePropertypublic <V> Optional<V> getTreeProperty(String key, Class<V> clazz) Description copied from interface:TreeNodeConvenience method for obtaining a single property of tree that this node belongs to.- Specified by:
- getTreePropertyin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- Optionalwith a property value if it exists. Never returns- null
 
 - 
getIdpublic String getId() Description copied from interface:TreeNodeReturns ID of the node, which could match e.g. ID of the component with storage definition.- Specified by:
- getIdin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- Node ID
 
 - 
setIdpublic void setId(String id) 
 - 
findFirstDfspublic Optional<Self> findFirstDfs(Predicate<Self> visitor) Description copied from interface:TreeNodeDepth-first search for a node.- Specified by:
- findFirstDfsin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- 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.
 
 - 
findFirstBottommostDfspublic Optional<Self> findFirstBottommostDfs(Predicate<Self> visitor) Description copied from interface:TreeNodeDepth-first search for a node that is bottommost from those matching DFS.- Specified by:
- findFirstBottommostDfsin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- 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.
 
 - 
findFirstBfspublic Optional<Self> findFirstBfs(Predicate<Self> visitor) Description copied from interface:TreeNodeBreadth-first search for a node.- Specified by:
- findFirstBfsin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- 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.
 
 - 
walkBfspublic void walkBfs(Consumer<Self> visitor) Description copied from interface:TreeNodeWalks the tree with the given visitor in breadth-first search manner.- Specified by:
- walkBfsin interface- TreeNode<Self extends DefaultTreeNode<Self>>
 
 - 
walkDfspublic void walkDfs(Consumer<Self> visitorUponEntry, Consumer<Self> visitorAfterChildrenVisited) Description copied from interface:TreeNodeWalks the tree with the given visitor in depth-first search manner.- Specified by:
- walkDfsin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- 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.
 
 - 
forEachParentpublic void forEachParent(Consumer<Self> visitor) Description copied from interface:TreeNodeCalls the givenvisitoron each node laying on the path from this node (exclusive) to the root of the tree (inclusive).- Specified by:
- forEachParentin interface- TreeNode<Self extends DefaultTreeNode<Self>>
 
 - 
getPathToRootpublic List<Self> getPathToRoot(TreeNode.PathOrientation orientation) Description copied from interface:TreeNodeReturns the path (list of nodes) from this node to root node.- Specified by:
- getPathToRootin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- 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:
 
 - 
getChildrenpublic List<Self> getChildren() Description copied from interface:TreeNodeReturns the children of the current node. Order does matter.- Specified by:
- getChildrenin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- Read-only list of the children. Never returns null.
 
 - 
hasChildrenpublic boolean hasChildren() 
 - 
hasNoChildrenpublic boolean hasNoChildren() 
 - 
addChildpublic void addChild(Self node) Description copied from interface:TreeNodeAdds a node as a child of this node, and sets the parent of thenodeto this node.- Specified by:
- addChildin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Parameters:
- node- Future child node. If- nullor the node is already amongst the children list, no action is done.
 
 - 
addChildpublic void addChild(int index, Self node)Description copied from interface:TreeNodeAdds a node as a child of this node, and sets the parent of thenodeto this node.- Specified by:
- addChildin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- 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.
 
 - 
getChildpublic Optional<Self> getChild(String id) Description copied from interface:TreeNodeReturns a node by ID. If there are more nodes with the same ID, any node from those may be returned.- Specified by:
- getChildin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
 
 - 
removeChildpublic int removeChild(Predicate<Self> shouldRemove) Description copied from interface:TreeNodeRemoves child nodes satisfying the given predicate.- Specified by:
- removeChildin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- Number of removed nodes
 
 - 
removeChildpublic Optional<Self> removeChild(Self node) Description copied from interface:TreeNodeRemoves the given child node.- Specified by:
- removeChildin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Parameters:
- node- Node to remove
- Returns:
- Removed node
 
 - 
getParentpublic Optional<Self> getParent() Description copied from interface:TreeNodeReturns parent node or an emptyOptionalif this node is a root node.- Specified by:
- getParentin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
- See description. Never returns null.
 
 - 
setParentpublic void setParent(Self parent) Description copied from interface:TreeNodeSets 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.- Specified by:
- setParentin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Parameters:
- parent- New parent node or- nullif this node should be parentless.
 
 - 
cloneTreepublic <RNode extends TreeNode<? super RNode>> RNode cloneTree(Function<Self,RNode> instantiateFunc) 
 - 
getParentsStreampublic Stream<Self> getParentsStream() Description copied from interface:TreeNodeReturns a stream of the nodes laying on the path from this node (exclusive) to the root of the tree (inclusive).- Specified by:
- getParentsStreamin interface- TreeNode<Self extends DefaultTreeNode<Self>>
- Returns:
 
 - 
getLabelprotected String getLabel() 
 
- 
 
-