@Override public MutableTree clone() { MutableTree clone = new MutableTree(node); for (MutableTree child : this.childTrees.values()) { clone.childTrees.put(child.getNode().getName(), child.clone()); } return clone; } }
@Override public MutableTree clone() { MutableTree clone = new MutableTree(node); for (MutableTree child : this.childTrees.values()) { clone.childTrees.put(child.getNode().getName(), child.clone()); } return clone; } }
public void forceChild(final String parentPath, final Node treeNode) { ImmutableList<String> parentSteps = NodeRef.split(parentPath); MutableTree parent = this; for (String name : parentSteps) { MutableTree child = parent.childTrees.get(name); if (child == null) { child = new MutableTree(name); parent.childTrees.put(name, child); } parent = child; } MutableTree tree = parent.childTrees.get(treeNode.getName()); if (tree == null) { tree = new MutableTree(treeNode); parent.childTrees.put(treeNode.getName(), tree); } else { tree.setNode(treeNode); } }
public void forceChild(final String parentPath, final Node treeNode) { List<String> parentSteps = NodeRef.split(parentPath); MutableTree parent = this; for (String name : parentSteps) { MutableTree child = parent.childTrees.get(name); if (child == null) { child = new MutableTree(name); parent.childTrees.put(name, child); } parent = child; } MutableTree tree = parent.childTrees.get(treeNode.getName()); if (tree == null) { tree = new MutableTree(treeNode); parent.childTrees.put(treeNode.getName(), tree); } else { tree.setNode(treeNode); } }
public void setChild(final List<String> parentPath, final Node node) { MutableTree parent; MutableTree child; if (parentPath.isEmpty()) { parent = this; } else { parent = getChild(parentPath); } child = parent.childTrees.get(node.getName()); if (child == null) { child = new MutableTree(node); parent.childTrees.put(node.getName(), child); } else { child.setNode(node); } }
public void setChild(final List<String> parentPath, final Node node) { MutableTree parent; MutableTree child; if (parentPath.isEmpty()) { parent = this; } else { parent = getChild(parentPath); } child = parent.childTrees.get(node.getName()); if (child == null) { child = new MutableTree(node); parent.childTrees.put(node.getName(), child); } else { child.setNode(node); } }
public static MutableTree createFromPaths(final ObjectId rootId, final Map<String, NodeRef> entries) { List<NodeRef> refsByDepth = Lists.newArrayList(entries.values()); Collections.sort(refsByDepth, DEEPEST_LAST_COMPARATOR); Node rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, null); MutableTree root = new MutableTree(rootNode); Envelope bounds = new Envelope(); for (NodeRef entry : refsByDepth) { Node node = entry.getNode(); node.expand(bounds); String parentPath = entry.getParentPath(); root.setChild(parentPath, node); } // recreate root node with the appropriate bounds rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, bounds); root.setNode(rootNode); return root; }
public static MutableTree createFromPaths(final ObjectId rootId, final Map<String, NodeRef> entries) { List<NodeRef> refsByDepth = Lists.newArrayList(entries.values()); Collections.sort(refsByDepth, DEEPEST_LAST_COMPARATOR); Node rootNode = RevObjectFactory.defaultInstance().createNode(ROOT, rootId, ObjectId.NULL, TYPE.TREE, null, null); MutableTree root = new MutableTree(rootNode); Envelope bounds = new Envelope(); for (NodeRef entry : refsByDepth) { Node node = entry.getNode(); node.expand(bounds); String parentPath = entry.getParentPath(); root.setChild(parentPath, node); } // recreate root node with the appropriate bounds rootNode = RevObjectFactory.defaultInstance().createNode(ROOT, rootId, ObjectId.NULL, TYPE.TREE, bounds, null); root.setNode(rootNode); return root; }