@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; }
@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; }
@NotNull @Override public NodeBuilder setProperty(@NotNull PropertyState property) { checkState(exists(), "This builder does not exist: " + name); head().getMutableNodeState().setProperty(checkNotNull(property)); updated(); return this; }
@Override public MutableNodeState getMutableNodeState() { // switch to connected state recursively up to the parent MutableNodeState parentState = builder.parent.head().getMutableNodeState(); MutableNodeState state = parentState.getMutableChildNode(builder.name); // triggers a head state transition at next access return new ConnectedHead(builder, state).getMutableNodeState(); }
@Nonnull @Override public NodeBuilder removeProperty(String name) { checkState(exists(), "This builder does not exist: " + name); if (head().getMutableNodeState().removeProperty(checkNotNull(name))) { updated(); } return this; }
@Nonnull @Override public NodeBuilder setProperty(@Nonnull PropertyState property) { checkState(exists(), "This builder does not exist: " + name); head().getMutableNodeState().setProperty(checkNotNull(property)); updated(); return this; }
@Override public MutableNodeState getMutableNodeState() { // switch to connected state recursively up to the parent MutableNodeState parentState = builder.parent.head().getMutableNodeState(); MutableNodeState state = parentState.getMutableChildNode(builder.name); // triggers a head state transition at next access return new ConnectedHead(builder, state).getMutableNodeState(); }
@NotNull @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; } }