Class ModelTransaction.ChildrenUpdateOperation
java.lang.Object
org.apache.commons.configuration2.tree.ModelTransaction.Operation
org.apache.commons.configuration2.tree.ModelTransaction.ChildrenUpdateOperation
- Enclosing class:
ModelTransaction
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 Summary
FieldsModifier and TypeFieldDescriptionprivate Collection
<ImmutableNode> A collection with new nodes to be added.private Set
<ImmutableNode> A collection with nodes to be removed.private Map
<ImmutableNode, ImmutableNode> A map with nodes to be replaced by others. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNewNode
(ImmutableNode node) Adds a node to be added to the target of the operation.void
addNewNodes
(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
Adds all operations defined by the specified object to this instance.private Set
<ImmutableNode> Returns a set with nodes to be removed.private Map
<ImmutableNode, ImmutableNode> Obtains the map with replacement nodes.
-
Field Details
-
newNodes
A collection with new nodes to be added. -
nodesToRemove
A collection with nodes to be removed. -
nodesToReplace
A map with nodes to be replaced by others. The keys are the nodes to be replaced, the values the replacements.
-
-
Constructor Details
-
ChildrenUpdateOperation
private ChildrenUpdateOperation()
-
-
Method Details
-
addNewNode
Adds a node to be added to the target of the operation.- Parameters:
node
- the new node to be added
-
addNewNodes
Adds a collection of nodes to be added to the target of the operation.- Parameters:
nodes
- the collection with new nodes
-
addNodeToRemove
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
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
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
Adds all operations defined by the specified object to this instance.- Parameters:
op
- the operation to be combined
-
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
Obtains the map with replacement nodes. If no replacements are defined, an empty map is returned.- Returns:
- the map with replacement nodes
-