/** * Called whenever <em>this</em> node is modified, i.e. a property is * added, changed or removed, or a child node is added or removed. Changes * inside child nodes or the subtrees below are not reported. The default * implementation triggers an {@link #updated()} call on the root builder * (unless this is already the root builder), which subclasses can use * to capture aggregate update information across the whole tree. */ protected void updated() { if (this != rootBuilder) { rootBuilder.updated(); } }
/** * Called whenever <em>this</em> node is modified, i.e. a property is * added, changed or removed, or a child node is added or removed. Changes * inside child nodes or the subtrees below are not reported. The default * implementation triggers an {@link #updated()} call on the root builder * (unless this is already the root builder), which subclasses can use * to capture aggregate update information across the whole tree. */ protected void updated() { if (this != rootBuilder) { rootBuilder.updated(); } }
@Override protected void updated() { if (isChildBuilder()) { super.updated(); } else { updateCount++; if (updateCount > UPDATE_LIMIT) { getNodeState(); } } }
@NotNull @Override public NodeBuilder setProperty(@NotNull PropertyState property) { checkState(exists(), "This builder does not exist: " + name); head().getMutableNodeState().setProperty(checkNotNull(property)); updated(); return this; }
@Nonnull @Override public NodeBuilder setChildNode(@Nonnull String name, @Nonnull NodeState state) { checkState(exists(), "This builder does not exist: " + this.name); head().getMutableNodeState().setChildNode(name, checkNotNull(state)); MemoryNodeBuilder builder = createChildBuilder(name); updated(); return builder; }
@Nonnull @Override public NodeBuilder setProperty(@Nonnull PropertyState property) { checkState(exists(), "This builder does not exist: " + name); head().getMutableNodeState().setProperty(checkNotNull(property)); updated(); return this; }
@NotNull @Override public NodeBuilder removeProperty(String name) { checkState(exists(), "This builder does not exist: " + name); if (head().getMutableNodeState().removeProperty(checkNotNull(name))) { updated(); } return this; }
@NotNull @Override public NodeBuilder setChildNode(@NotNull String name, @NotNull NodeState state) { checkState(exists(), "This builder does not exist: " + this.name); head().getMutableNodeState().setChildNode(name, checkNotNull(state)); MemoryNodeBuilder builder = createChildBuilder(name); updated(); return builder; }
@Nonnull @Override public NodeBuilder removeProperty(String name) { checkState(exists(), "This builder does not exist: " + name); if (head().getMutableNodeState().removeProperty(checkNotNull(name))) { updated(); } return this; }
@Override public boolean remove() { if (!isRoot() && exists()) { head().getMutableNodeState(); // Make sure the removed node is connected parent.head().getMutableNodeState().removeChildNode(name); updated(); return true; } else { return false; } }
@Override public boolean remove() { if (!isRoot() && exists()) { head().getMutableNodeState(); // Make sure the removed node is connected parent.head().getMutableNodeState().removeChildNode(name); updated(); return true; } else { return false; } }