protected void attachIfNecessary() { if (!attached) { getParentEnsureAttached().attachChild(this); } }
protected void attachIfNecessary() { if (!attached) { getParentEnsureAttached().attachChild(this); } }
/** * Clears the set value (or any attached child values) from this value */ void clear() { for (Iterator<SimpleConfigurationNode> it = iterateChildren().iterator(); it.hasNext();) { SimpleConfigurationNode node = it.next(); node.attached = false; it.remove(); if (node.getParentEnsureAttached().equals(holder)) { node.clear(); } } }
/** * Clears the set value (or any attached child values) from this value */ void clear() { for (Iterator<SimpleConfigurationNode> it = iterateChildren().iterator(); it.hasNext();) { SimpleConfigurationNode node = it.next(); node.attached = false; it.remove(); if (node.getParentEnsureAttached().equals(holder)) { node.clear(); } } }
/** * The same as {@link #getParent()} - but ensuring that 'parent' is attached via * {@link #attachChildIfAbsent(SimpleConfigurationNode)}. * * @return The parent */ SimpleConfigurationNode getParentEnsureAttached() { SimpleConfigurationNode parent = this.parent; if (parent.isVirtual()) { parent = parent.getParentEnsureAttached().attachChildIfAbsent(parent); } return this.parent = parent; }
/** * The same as {@link #getParent()} - but ensuring that 'parent' is attached via * {@link #attachChildIfAbsent(SimpleConfigurationNode)}. * * @return The parent */ SimpleConfigurationNode getParentEnsureAttached() { SimpleConfigurationNode parent = this.parent; if (parent.isVirtual()) { parent = parent.getParentEnsureAttached().attachChildIfAbsent(parent); } return this.parent = parent; }
if (!child.getParentEnsureAttached().equals(this)) { throw new IllegalStateException("Child " + child + " path is not a direct parent of me (" + this + "), cannot attach");
@Test public void testTraversingNodeCreation() { SimpleConfigurationNode config = SimpleConfigurationNode.root(); SimpleConfigurationNode nodeOne = config.getNode("uncreated", "step", "node"); SimpleConfigurationNode nodeTwo = config.getNode("uncreated", "step", "color"); nodeOne.setValue("one"); nodeTwo.setValue("lilac"); ConfigurationNode attachedParent = config.getNode("uncreated", "step"); assertEquals(attachedParent, nodeOne.getParentEnsureAttached()); assertEquals(attachedParent, nodeTwo.getParentEnsureAttached()); }
if (!child.getParentEnsureAttached().equals(this)) { throw new IllegalStateException("Child " + child + " path is not a direct parent of me (" + this + "), cannot attach");