Class ModelTransaction.ChildrenUpdateOperation

  • Enclosing class:
    ModelTransaction

    private final class ModelTransaction.ChildrenUpdateOperation
    extends ModelTransaction.Operation
    A specialized Operation implementation for replacing the children of a target node. All other properties are not touched. With this operation single children of a node can be altered or removed; new children can be added. This operation is frequently used because each update of a node causes updates of the children of all parent nodes. Therefore, it is treated in a special way and allows adding further sub operations dynamically.
    • Field Detail

      • newNodes

        private java.util.Collection<ImmutableNode> newNodes
        A collection with new nodes to be added.
      • nodesToRemove

        private java.util.Set<ImmutableNode> nodesToRemove
        A collection with nodes to be removed.
      • nodesToReplace

        private java.util.Map<ImmutableNode,​ImmutableNode> nodesToReplace
        A map with nodes to be replaced by others. The keys are the nodes to be replaced, the values the replacements.
    • Constructor Detail

      • ChildrenUpdateOperation

        private ChildrenUpdateOperation()
    • Method Detail

      • addNewNode

        public void addNewNode​(ImmutableNode node)
        Adds a node to be added to the target of the operation.
        Parameters:
        node - the new node to be added
      • addNewNodes

        public void addNewNodes​(java.util.Collection<? extends ImmutableNode> nodes)
        Adds a collection of nodes to be added to the target of the operation.
        Parameters:
        nodes - the collection with new nodes
      • addNodeToRemove

        public void addNodeToRemove​(ImmutableNode node)
        Adds a node for a remove operation. This child node is going to be removed from its parent.
        Parameters:
        node - the child node to be removed
      • addNodeToReplace

        public void addNodeToReplace​(ImmutableNode org,
                                     ImmutableNode replacement)
        Adds a node for a replacement operation. The original node is going to be replaced by its replacement.
        Parameters:
        org - the original node
        replacement - the replacement node
      • apply

        protected ImmutableNode apply​(ImmutableNode target,
                                      ModelTransaction.Operations operations)
        Executes this operation on the provided target node returning the result. This implementation applies changes on the children of the passed in target node according to its configuration: new nodes are added, replacements are performed, and nodes no longer needed are removed.
        Specified by:
        apply in class ModelTransaction.Operation
        Parameters:
        target - the target node for this operation
        operations - the current Operations instance
        Returns:
        the manipulated node
      • fetchRemovalSet

        private java.util.Set<ImmutableNode> fetchRemovalSet()
        Returns a set with nodes to be removed. If no remove operations are pending, an empty set is returned.
        Returns:
        the set with nodes to be removed
      • fetchReplacementMap

        private java.util.Map<ImmutableNode,​ImmutableNode> fetchReplacementMap()
        Obtains the map with replacement nodes. If no replacements are defined, an empty map is returned.
        Returns:
        the map with replacement nodes