DepTreeNode implements Cloneable, Serializable { @Override public DepTreeNode clone() throws CloneNotSupportedException { DepTreeNode clone = (DepTreeNode)super.clone(); if (children != null) { clone.children = new HashMap<String, DepTreeNode>(); for (Entry<String, DepTreeNode> entry : children.entrySet()) { DepTreeNode newNode = entry.getValue().clone(); clone.add(newNode); newNode.setParent(clone); } } if (defineDependencies != null) { clone.defineDependencies = Arrays.copyOf(defineDependencies, defineDependencies.length); } if (requireDependencies != null) { clone.requireDependencies = Arrays.copyOf(requireDependencies, requireDependencies.length); } clone.uri = uri; return clone; } DepTreeNode(String name, URI uri); String getName(); long lastModified(); long lastModifiedDep(); long lastModifiedDepTree(); DepTreeNode getParent(); DepTreeNode getRoot(); String[] getDefineDepArray(); String[] getRequireDepArray(); String[] getDependentFeatures(); String getParentPath(); String getFullPathName(); void add(DepTreeNode child); void overlay(DepTreeNode node); void addAll(Collection<DepTreeNode> children); DepTreeNode createOrGet(String path, URI uri); DepTreeNode getDescendent(String path); void remove(DepTreeNode child); void removeAll(); Map<String, DepTreeNode> getChildren(); DepTreeNode getChild(String name); void prune(); void setDependencies(String[] defineDependencies, String[] requireDependencies, String[] dependentFeatures, long lastModifiedFile, long lastModifiedDep); @Override String toString(); String toStringTree(); @Override DepTreeNode clone(); IConfig getConfig();  }
@Test public void testClone() { DepTreeNode root = new DepTreeNode("root", null); DepTreeNode child = root.createOrGet("child", null); root.setDependencies(new String[]{"a", "b"}, new String[]{"c", "d"}, new String[0], 0L, 1L); child.setDependencies(new String[]{"e", "f"}, new String[]{"g", "h"}, new String[0], 0L, 1L); DepTreeNode clone = null; try { clone = (DepTreeNode)root.clone(); } catch (CloneNotSupportedException e) { fail(e.getMessage()); } assertArrayEquals(root.getDefineDepArray(), clone.getDefineDepArray()); assertNotSame(root.getDefineDepArray(), clone.getDefineDepArray()); assertArrayEquals(root.getRequireDepArray(), clone.getRequireDepArray()); assertNotSame(root.getRequireDepArray(), clone.getRequireDepArray()); assertEquals(root.lastModified(), clone.lastModified()); assertEquals(root.lastModifiedDep(), clone.lastModifiedDep()); DepTreeNode clonedChild = clone.getChild("child"); assertArrayEquals(child.getDefineDepArray(), clonedChild.getDefineDepArray()); assertNotSame(child.getDefineDepArray(), clonedChild.getDefineDepArray()); assertArrayEquals(child.getRequireDepArray(), clonedChild.getRequireDepArray()); assertNotSame(child.getRequireDepArray(), clonedChild.getRequireDepArray()); assertEquals(child.lastModified(), clonedChild.lastModified()); assertEquals(child.lastModifiedDep(), clonedChild.lastModifiedDep()); }