TreePath
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
class TreePath {
TreePath(int[] canonicalPath)
TreePath of(int... canonicalPath)
TreePath root()
int size() (1)
TreePath append(int indexWithinSiblings) (2)
TreePath subPath(int startIndex) (3)
TreePath getParentIfAny() (4)
boolean isRoot()
boolean startsWith(TreePath other)
IntStream streamPathElements()
OptionalInt childIndex() (5)
String stringify(String delimiter)
Stream<TreePath> streamUpTheHierarchyStartingAtSelf()
TreePath parse(String treePathStringified, String delimiter) (6)
boolean equals(Object obj)
int hashCode()
String toString()
}
1 | size()
Number of path-elements. |
2 | append(int) |
3 | subPath(int)
Returns a sub-path containing all the path-elements of this path, skipping startIndex number of path elements at the start. |
4 | getParentIfAny()
Returns a TreePath instance that represents the parent path of this TreePath, if this is not the root. |
5 | 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. |
6 | parse(String, String)
Parses stringified tree path of format 031 …, as returned by TreePath#stringify(String) . |
Members
subPath(int)
Returns a sub-path containing all the path-elements of this path, skipping startIndex number of path elements at the start.
getParentIfAny()
Returns a TreePath instance that represents the parent path of this TreePath, if this is not the root.