public void addChild(PrefetchTreeNode child) { if (Util.isEmptyString(child.getName())) { throw new IllegalArgumentException("Child has no segmentPath: " + child); } if (child.getParent() != this) { child.getParent().removeChild(child.getName()); child.parent = this; } if (children == null) { children = new ArrayList(4); } children.add(child); }
public void addChild(PrefetchTreeNode child) { if (Util.isEmptyString(child.getName())) { throw new IllegalArgumentException("Child has no segmentPath: " + child); } if (child.getParent() != this) { child.getParent().removeChild(child.getName()); child.parent = this; } if (children == null) { children = new ArrayList<>(4); } children.add(child); }
/** * Removes or makes phantom a node defined by this path. If the node for this path * doesn't have any children, it is removed, otherwise it is made phantom. */ public void removePath(String path) { PrefetchTreeNode node = getNode(path); while (node != null) { if (node.children != null) { node.setPhantom(true); break; } String segment = node.getName(); node = node.getParent(); if (node != null) { node.removeChild(segment); } } }
/** * Removes or makes phantom a node defined by this path. If the node for * this path doesn't have any children, it is removed, otherwise it is made * phantom. */ public void removePath(String path) { PrefetchTreeNode node = getNode(path); while (node != null) { if (node.children != null) { node.setPhantom(true); break; } String segment = node.getName(); node = node.getParent(); if (node != null) { node.removeChild(segment); } } }