Class ModelTransaction.ChildrenUpdateOperation
- java.lang.Object
-
- org.apache.commons.configuration2.tree.ModelTransaction.Operation
-
- org.apache.commons.configuration2.tree.ModelTransaction.ChildrenUpdateOperation
-
- Enclosing class:
- ModelTransaction
private final class ModelTransaction.ChildrenUpdateOperation extends ModelTransaction.Operation
A specializedOperation
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 Summary
Fields Modifier and Type Field Description private java.util.Collection<ImmutableNode>
newNodes
A collection with new nodes to be added.private java.util.Set<ImmutableNode>
nodesToRemove
A collection with nodes to be removed.private java.util.Map<ImmutableNode,ImmutableNode>
nodesToReplace
A map with nodes to be replaced by others.
-
Constructor Summary
Constructors Modifier Constructor Description private
ChildrenUpdateOperation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addNewNode(ImmutableNode node)
Adds a node to be added to the target of the operation.void
addNewNodes(java.util.Collection<? extends ImmutableNode> nodes)
Adds a collection of nodes to be added to the target of the operation.void
addNodeToRemove(ImmutableNode node)
Adds a node for a remove operation.void
addNodeToReplace(ImmutableNode org, ImmutableNode replacement)
Adds a node for a replacement operation.protected ImmutableNode
apply(ImmutableNode target, ModelTransaction.Operations operations)
Executes this operation on the provided target node returning the result.void
combine(ModelTransaction.ChildrenUpdateOperation op)
Adds all operations defined by the specified object to this instance.private java.util.Set<ImmutableNode>
fetchRemovalSet()
Returns a set with nodes to be removed.private java.util.Map<ImmutableNode,ImmutableNode>
fetchReplacementMap()
Obtains the map with replacement nodes.
-
-
-
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.
-
-
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 nodereplacement
- 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 classModelTransaction.Operation
- Parameters:
target
- the target node for this operationoperations
- the currentOperations
instance- Returns:
- the manipulated node
-
combine
public void combine(ModelTransaction.ChildrenUpdateOperation op)
Adds all operations defined by the specified object to this instance.- Parameters:
op
- the operation to be combined
-
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
-
-