@Test public void testGetOrAddTreeSingleElement() throws Exception { Tree child = Utils.getOrAddTree(tree, "child", NodeTypeConstants.NT_OAK_UNSTRUCTURED); assertEqualPath(root.getTree("/child"), child); }
@NotNull static Tree getOrAddTree(@NotNull Tree tree, @NotNull String relativePath, @NotNull String primaryTypeName) throws AccessDeniedException { if (PathUtils.denotesCurrent(relativePath)) { return tree; } else if (PathUtils.denotesParent(relativePath)) { return tree.getParent(); } else if (relativePath.indexOf('/') == -1) { return TreeUtil.getOrAddChild(tree, relativePath, primaryTypeName); } else { for (String element : PathUtils.elements(relativePath)) { if (PathUtils.denotesParent(element)) { tree = tree.getParent(); } else if (!PathUtils.denotesCurrent(element)) { tree = TreeUtil.getOrAddChild(tree, element, primaryTypeName); } } return tree; } }
Utils { @NotNull static Tree getOrAddTree(@NotNull Tree tree, @NotNull String relativePath, @NotNull String primaryTypeName) throws AccessDeniedException { if (PathUtils.denotesCurrent(relativePath)) { return tree; } else if (PathUtils.denotesParent(relativePath)) { return tree.getParent(); } else if (relativePath.indexOf('/') == -1) { return TreeUtil.getOrAddChild(tree, relativePath, primaryTypeName); } else { for (String element : PathUtils.elements(relativePath)) { if (PathUtils.denotesParent(element)) { tree = tree.getParent(); } else if (!PathUtils.denotesCurrent(element)) { tree = TreeUtil.getOrAddChild(tree, element, primaryTypeName); } } return tree; } } }
Utils { @NotNull static Tree getOrAddTree(@NotNull Tree tree, @NotNull String relativePath, @NotNull String primaryTypeName) throws AccessDeniedException { if (PathUtils.denotesCurrent(relativePath)) { return tree; } else if (PathUtils.denotesParent(relativePath)) { return tree.getParent(); } else if (relativePath.indexOf('/') == -1) { return TreeUtil.getOrAddChild(tree, relativePath, primaryTypeName); } else { for (String element : PathUtils.elements(relativePath)) { if (PathUtils.denotesParent(element)) { tree = tree.getParent(); } else if (!PathUtils.denotesCurrent(element)) { tree = TreeUtil.getOrAddChild(tree, element, primaryTypeName); } } return tree; } } private  Utils(); }
Utils { @NotNull static Tree getOrAddTree(@NotNull Tree tree, @NotNull String relativePath, @NotNull String primaryTypeName) throws AccessDeniedException { if (PathUtils.denotesCurrent(relativePath)) { return tree; } else if (PathUtils.denotesParent(relativePath)) { return tree.getParent(); } else if (relativePath.indexOf('/') == -1) { return TreeUtil.getOrAddChild(tree, relativePath, primaryTypeName); } else { for (String element : PathUtils.elements(relativePath)) { if (PathUtils.denotesParent(element)) { tree = tree.getParent(); } else if (!PathUtils.denotesCurrent(element)) { tree = TreeUtil.getOrAddChild(tree, element, primaryTypeName); } } return tree; } } private  Utils();  }
Utils { @NotNull static Tree getOrAddTree(@NotNull Tree tree, @NotNull String relativePath, @NotNull String primaryTypeName) throws AccessDeniedException { if (PathUtils.denotesCurrent(relativePath)) { return tree; } else if (PathUtils.denotesParent(relativePath)) { return tree.getParent(); } else if (relativePath.indexOf('/') == -1) { return TreeUtil.getOrAddChild(tree, relativePath, primaryTypeName); } else { for (String element : PathUtils.elements(relativePath)) { if (PathUtils.denotesParent(element)) { tree = tree.getParent(); } else if (!PathUtils.denotesCurrent(element)) { tree = TreeUtil.getOrAddChild(tree, element, primaryTypeName); } } return tree; } } private  Utils();   }