/** * @param treeNode Tree node. * @param prefix Prefix. * @param tail Tail child. * @param a Output. * @throws IOException If failed. */ private void printTree(T treeNode, String prefix, boolean tail, Appendable a) throws IOException { List<T> children = getChildren(treeNode); int cnt = children == null ? 0 : children.size(); a.append(prefix).append(tail ? "└── " : "├── ").append(formatTreeNode(treeNode)).append('\n'); String childPrefix = prefix + (tail ? " " : "│ "); if (children == null) a.append(childPrefix).append("└── <list of children is not accessible>\n"); else { for (int i = 0; i < cnt; i++) printTree(children.get(i), childPrefix, i == cnt - 1, a); } }
/** * @param treeNode Tree node. * @param prefix Prefix. * @param tail Tail child. * @param a Output. * @throws IOException If failed. */ private void printTree(T treeNode, String prefix, boolean tail, Appendable a) throws IOException { List<T> children = getChildren(treeNode); int cnt = children == null ? 0 : children.size(); a.append(prefix).append(tail ? "└── " : "├── ").append(formatTreeNode(treeNode)).append('\n'); String childPrefix = prefix + (tail ? " " : "│ "); if (children == null) a.append(childPrefix).append("└── <list of children is not accessible>\n"); else { for (int i = 0; i < cnt; i++) printTree(children.get(i), childPrefix, i == cnt - 1, a); } }