java.lang.Object
org.neo4j.cypherdsl.core.TreeNode<E>
- Type Parameters:
E- the type of each node value
A mutable tree structure providing
Breadth-first search
(aka in-level order traversal) and pre-ordered
depth-first search. This
class is thread-safe.
- Since:
- 2023.2.0
- Author:
- Michael J. Simons
-
Method Summary
Modifier and TypeMethodDescriptionReturns a breadth-first iterator of this node and it's children.Creates a tree from aStatement.Returns an immutable collection of this nodes children.intgetLevel()Returns the level or the height in this tree in which0is the level of the root node.Returns the parent of this node ornullif this is a root node.getValue()Returns the value of this node.booleanisRoot()Returnstrueif this is the root node.preOrder()Returns a depth-first, pre-ordered iterator of this node and it's children.voidCreates an ASCII representation of this node and its children.
-
Method Details
-
from
Creates a tree from aStatement. This allows to visit all elements of statement without implementing customvisitors.The root of the returned tree will always be the statement.- Parameters:
statement- the statement that should be represented as a tree- Returns:
- a tree with the statement as root
-
isRoot
public boolean isRoot()Returnstrueif this is the root node.- Returns:
trueif this is the root node
-
getLevel
public int getLevel()Returns the level or the height in this tree in which0is the level of the root node.- Returns:
- the level or the height in this tree
-
getParent
Returns the parent of this node ornullif this is a root node.- Returns:
- the parent of this node or
nullif this is a root node
-
getChildren
Returns an immutable collection of this nodes children.- Returns:
- an immutable collection of this nodes children
-
getValue
Returns the value of this node.- Returns:
- the value of this node
-
breadthFirst
Returns a breadth-first iterator of this node and it's children.- Returns:
- a breadth-first iterator of this node and it's children
-
preOrder
Returns a depth-first, pre-ordered iterator of this node and it's children.- Returns:
- a depth-first, pre-ordered iterator of this node and it's children
-
printTo
Creates an ASCII representation of this node and its children.- Parameters:
target- the target to which to print this tree totoString- how to format nodes if this type
-