/** * Creates a new in-memory node state builder rooted at * and based on the passed {@code base} state. * @param base base state of the new builder */ public MemoryNodeBuilder(@Nonnull NodeState base) { this.parent = null; this.name = null; this.rootBuilder = this; this.baseRevision = 0; this.base = checkNotNull(base); this.rootHead = new RootHead(this); this.head = rootHead; }
/** * Throws away all changes in this builder and resets the base to the * given node state. * * @param newBase new base state */ public void reset(@NotNull NodeState newBase) { checkState(parent == null); base = checkNotNull(newBase); baseRevision = rootHead.setState(newBase) + 1; }
/** * Replaces the current state of this builder with the given node state. * The base state remains unchanged. * * @param newState new state */ protected void set(NodeState newState) { if (parent == null) { // updating the base revision forces all sub-builders to refresh baseRevision = rootHead.setState(newState); } else { parent.setChildNode(name, newState); } }
/** * Replaces the current state of this builder with the given node state. * The base state remains unchanged. * * @param newState new state */ protected void set(NodeState newState) { if (parent == null) { // updating the base revision forces all sub-builders to refresh baseRevision = rootHead.setState(newState); } else { parent.setChildNode(name, newState); } }
/** * Creates a new in-memory node state builder rooted at * and based on the passed {@code base} state. * @param base base state of the new builder */ public MemoryNodeBuilder(@NotNull NodeState base) { this.parent = null; this.name = null; this.rootBuilder = this; this.baseRevision = 0; this.base = checkNotNull(base); this.rootHead = new RootHead(this); this.head = rootHead; }
/** * Throws away all changes in this builder and resets the base to the * given node state. * * @param newBase new base state */ public void reset(@Nonnull NodeState newBase) { checkState(parent == null); base = checkNotNull(newBase); baseRevision = rootHead.setState(newBase) + 1; }