if (childrenOperation != null) node = childrenOperation.apply(node, this);
fetchReplacementMap(); final Set<ImmutableNode> removals = fetchRemovalSet(); final List<ImmutableNode> resultNodes = new LinkedList<>();
/** * Propagates the changes on the target node to the next level above of * the hierarchy. If the updated node is no longer defined, it can even * be removed from its parent. Otherwise, it is just replaced. * * @param target the target node for this operation * @param node the resulting node after applying all operations * @param level the level of the target node */ private void propagateChange(final ImmutableNode target, final ImmutableNode node, final int level) { final ImmutableNode parent = getParent(target); final ChildrenUpdateOperation co = new ChildrenUpdateOperation(); if (InMemoryNodeModel.checkIfNodeDefined(node)) { co.addNodeToReplace(target, node); } else { co.addNodeToRemove(target); } fetchOperations(parent, level - 1).addChildrenOperation(co); }
/** * Adds an operation which manipulates children. * * @param co the operation */ public void addChildrenOperation(final ChildrenUpdateOperation co) { if (childrenOperation == null) { childrenOperation = co; } else { childrenOperation.combine(co); } }
/** * Adds an operation for adding a number of new children to a given parent * node. * * @param parent the parent node * @param newNodes the collection of new child nodes */ public void addAddNodesOperation(final ImmutableNode parent, final Collection<? extends ImmutableNode> newNodes) { final ChildrenUpdateOperation op = new ChildrenUpdateOperation(); op.addNewNodes(newNodes); fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op); }
/** * Adds an operation for removing a child node of a given node. * * @param parent the parent node * @param node the child node to be removed */ public void addRemoveNodeOperation(final ImmutableNode parent, final ImmutableNode node) { final ChildrenUpdateOperation op = new ChildrenUpdateOperation(); op.addNodeToRemove(node); fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op); }
/** * Adds an operation for adding a new child to a given parent node. * * @param parent the parent node * @param newChild the new child to be added */ public void addAddNodeOperation(final ImmutableNode parent, final ImmutableNode newChild) { final ChildrenUpdateOperation op = new ChildrenUpdateOperation(); op.addNewNode(newChild); fetchOperations(parent, LEVEL_UNKNOWN).addChildrenOperation(op); }