+ + operation + ", childModification=" + children + "]";
+ }
+
+ void resolveModificationType(@Nonnull final ModificationType type) {
+ modType = type;
+ }
+
+ @Nonnull ModificationType modificationType() {
+ return Verify.verifyNotNull(modType, "Node %s does not have resolved modification type", this);
+ }
+
+ /**
+ * Create a node which will reflect the state of this node, except it will behave as newly-written
+ * value. This is useful only for merge validation.
+ *
+ * @param value Value associated with the node
+ * @return An isolated node. This node should never reach a datatree.
+ */
+ ModifiedNode asNewlyWritten(final NormalizedNode<?, ?> value) {
+ /*
+ * We are instantiating an "equivalent" of this node. Currently the only callsite does not care
+ * about the actual iteration order, so we do not have to specify the same tracking policy as
+ * we were instantiated with. Since this is the only time we need to know that policy (it affects
+ * only things in constructor), we do not want to retain it (saves some memory on per-instance
+ * basis).
+ *
+ * We could reconstruct it using two instanceof checks (to undo what the constructor has done),
+ * which would give perfect results. The memory saving would be at most 32 bytes of a short-lived
+ * object, so let's not bother with that.
+ */
+ final ModifiedNode ret = new ModifiedNode(getIdentifier(), Optional.<TreeNode>absent(), ChildTrackingPolicy.UNORDERED);
+ ret.write(value);
+ return ret;