public final long setState(NodeState state) { this.state = new MutableNodeState(state); // To be able to make a distinction between set() and reset(), we revision++; // increment the revision twice and return revision++; // return the intermediate value }
public final long setState(NodeState state) { this.state = new MutableNodeState(state); // To be able to make a distinction between set() and reset(), we revision++; // increment the revision twice and return revision++; // return the intermediate value }
public RootHead(MemoryNodeBuilder builder) { // Base of root is always up to date. No need to call base() super(builder, new MutableNodeState(builder.base)); }
public RootHead(MemoryNodeBuilder builder) { // Base of root is always up to date. No need to call base() super(builder, new MutableNodeState(builder.base)); }
/** * Returns a mutable child node with the given name. If the named * child node has already been modified, i.e. there's an entry for * it in the {@link #nodes} map, then that child instance is returned * directly. Otherwise a new mutable child instance is created based * on the (possibly non-existent) respective child node of the base * state, added to the {@link #nodes} map and returned. */ MutableNodeState getMutableChildNode(String name) { assert base != null; MutableNodeState child = nodes.get(name); if (child == null) { child = new MutableNodeState(base.getChildNode(name)); nodes.put(name, child); } return child; }
/** * Returns a mutable child node with the given name. If the named * child node has already been modified, i.e. there's an entry for * it in the {@link #nodes} map, then that child instance is returned * directly. Otherwise a new mutable child instance is created based * on the (possibly non-existent) respective child node of the base * state, added to the {@link #nodes} map and returned. */ MutableNodeState getMutableChildNode(String name) { assert base != null; MutableNodeState child = nodes.get(name); if (child == null) { child = new MutableNodeState(base.getChildNode(name)); nodes.put(name, child); } return child; }
String name = entry.getKey(); if (!nodes.containsKey(name)) { nodes.put(name, new MutableNodeState(entry.getValue()));
String name = entry.getKey(); if (!nodes.containsKey(name)) { nodes.put(name, new MutableNodeState(entry.getValue()));
/** * Remove the child node with the given {@code name}. * @param name name of the child node to remove * @return {@code true} if a child node {@code name} existed, {@code false} otherwise. */ boolean removeChildNode(String name) { assert base != null; MutableNodeState child = nodes.get(name); if (child != null) { boolean existed = child.exists(); child.reset(MISSING_NODE); return existed; } else { nodes.put(name, new MutableNodeState(MISSING_NODE)); return base.hasChildNode(name); } }
/** * Remove the child node with the given {@code name}. * @param name name of the child node to remove * @return {@code true} if a child node {@code name} existed, {@code false} otherwise. */ boolean removeChildNode(String name) { assert base != null; MutableNodeState child = nodes.get(name); if (child != null) { boolean existed = child.exists(); child.reset(MISSING_NODE); return existed; } else { nodes.put(name, new MutableNodeState(MISSING_NODE)); return base.hasChildNode(name); } }
/** * Equivalent to * <pre> * MutableNodeState child = getChildNode(name, true); * child.reset(state); * return child; * </pre> * * @throws IllegalArgumentException if the given name string is empty * or contains the forward slash character */ @NotNull MutableNodeState setChildNode(String name, NodeState state) throws IllegalArgumentException { assert base != null; MutableNodeState child = nodes.get(name); if (child == null) { checkValidName(name); child = new MutableNodeState(state); if (base.hasChildNode(name)) { child.replaced = true; } nodes.put(name, child); } else { child.replaced = true; child.reset(state); } return child; }
/** * Equivalent to * <pre> * MutableNodeState child = getChildNode(name, true); * child.reset(state); * return child; * </pre> * * @throws IllegalArgumentException if the given name string is empty * or contains the forward slash character */ @Nonnull MutableNodeState setChildNode(String name, NodeState state) throws IllegalArgumentException { assert base != null; MutableNodeState child = nodes.get(name); if (child == null) { checkValidName(name); child = new MutableNodeState(state); if (base.hasChildNode(name)) { child.replaced = true; } nodes.put(name, child); } else { child.replaced = true; child.reset(state); } return child; }