- private void recursiveMerge(final NormalizedNode<?,?> data) {
- if (data instanceof NormalizedNodeContainer) {
- @SuppressWarnings({ "rawtypes", "unchecked" })
- final
- NormalizedNodeContainer<?,?,NormalizedNode<PathArgument, ?>> dataContainer = (NormalizedNodeContainer) data;
-
- /*
- * if there was write before on this node and it is of NormalizedNodeContainer type
- * merge would overwrite our changes. So we create write modifications from data children to
- * retain children created by past write operation.
- * These writes will then be pushed down in the tree while there are merge modifications on these children
- */
- if (modification.getOperation() == LogicalOperation.WRITE) {
- @SuppressWarnings({ "rawtypes", "unchecked" })
- final
- NormalizedNodeContainer<?,?,NormalizedNode<PathArgument, ?>> odlDataContainer =
- (NormalizedNodeContainer) modification.getWrittenValue();
- for (final NormalizedNode<PathArgument, ?> child : odlDataContainer.getValue()) {
- final PathArgument childId = child.getIdentifier();
- forChild(childId).write(child);
- }
- }
- for (final NormalizedNode<PathArgument, ?> child : dataContainer.getValue()) {
- final PathArgument childId = child.getIdentifier();
- forChild(childId).recursiveMerge(child);
- }
- }
-
- modification.merge(data);
- }
-
- void merge(final NormalizedNode<?, ?> data) {