TreePath (record)
Provides an unambiguous way to address nodes by position within a tree-structure. Examples:
-
/0 … the tree root
-
/0/1 … the second child of root
-
/0/0/0 … the first child of first child of root
API
record TreePath {
TreePath(int[] canonicalPath)
TreePath parse(String treePathStringified, String delimiter) (1)
TreePath of(int... canonicalPath)
TreePath root()
int size() (2)
TreePath append(int indexWithinSiblings) (3)
TreePath subPath(int startIndex) (4)
Optional<TreePath> parent() (5)
boolean isRoot()
boolean startsWith(TreePath other)
IntStream streamPathElements()
OptionalInt childIndex() (6)
String stringify(String delimiter)
Stream<TreePath> streamUpTheHierarchyStartingAtSelf()
boolean equals(Object obj)
int hashCode()
String toString()
}
1 | parse(String, String)
Parses stringified tree path of format 031 …, as returned by TreePath#stringify(String) . |
2 | size()
Number of path-elements. |
3 | append(int) |
4 | subPath(int)
Returns a sub-path containing all the path-elements of this path, skipping startIndex number of path elements at the start. |
5 | parent()
Returns a TreePath instance that represents the parent path of this TreePath, if this is not the root. |
6 | childIndex()
Optionally the 2nd path-element’s value, based on presence. It corresponds to the sibling index of the child node this tree-path (either directly references or) includes. |
Members
parse(String, String)
Parses stringified tree path of format 031 …, as returned by TreePath#stringify(String) .
For null or empty input the root is returned.
subPath(int)
Returns a sub-path containing all the path-elements of this path, skipping startIndex number of path elements at the start.