BUG-4684: validate changes against effective state
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / ModificationApplyOperation.java
index 115b844e92bd74bbe2eac610c01947ae55373bba..83c9b6d0411c5146ba156a03a9f7376e9ebebffa 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 import com.google.common.base.Optional;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
@@ -56,26 +57,48 @@ abstract class ModificationApplyOperation implements StoreTreeNode<ModificationA
     abstract Optional<TreeNode> apply(ModifiedNode modification, Optional<TreeNode> storeMeta, Version version);
 
     /**
-    *
-    * Checks if provided node modification could be applied to current metadata node.
-    *
-    * @param modification Modification
-    * @param current Metadata Node to which modification should be applied
-    * @return true if modification is applicable
-    *         false if modification is no applicable
-    * @throws DataValidationFailedException
-    */
-   abstract void checkApplicable(YangInstanceIdentifier path, NodeModification modification, Optional<TreeNode> current) throws DataValidationFailedException;
+     *
+     * Checks if provided node modification could be applied to current metadata node.
+     *
+     * @param modification Modification
+     * @param current Metadata Node to which modification should be applied
+     * @param version
+     * @return true if modification is applicable
+     *         false if modification is no applicable
+     * @throws DataValidationFailedException
+     */
+   abstract void checkApplicable(YangInstanceIdentifier path, NodeModification modification, Optional<TreeNode> current, Version version) throws DataValidationFailedException;
+
+    /**
+     *
+     * Performs structural verification of NodeModification, such as writen values / types uses
+     * right structural elements.
+     *
+     * @param modification data to be verified.
+     * @param verifyChildren true if structure verification should be run against children.
+     * @throws IllegalArgumentException If provided NodeModification does not adhere to the
+     *         structure.
+     */
+    abstract void verifyStructure(NormalizedNode<?, ?> modification, boolean verifyChildren)
+            throws IllegalArgumentException;
 
     /**
+     * Return the tracking policy for this node's children.
      *
-     * Performs structural verification of NodeModification, such as writen values / types
-     * uses right structural elements.
+     * @return Tracking policy, may not be null.
+     */
+    abstract ChildTrackingPolicy getChildPolicy();
+
+    /**
+     * Stage a merge operation into a {@link ModifiedNode} such that it will be processed correctly by
+     * {@link #apply(ModifiedNode, Optional, Version)}. This method is the context which is introducing this operation,
+     * and so any overheads are charged to whoever is in control of the access pattern.
      *
-     * @param modification to be verified.
-     * @throws IllegalArgumentException If provided NodeModification does not adhere to the structure.
+     * @param modification Original modification node
+     * @param value Value which should be merge into the modification
+     * @param version Data version as carried in the containing {@link InMemoryDataTreeModification}
      */
-    abstract void verifyStructure(ModifiedNode modification) throws IllegalArgumentException;
+    abstract void mergeIntoModifiedNode(ModifiedNode modification, NormalizedNode<?, ?> value, Version version);
 
     /**
      * Returns a suboperation for specified tree node
@@ -85,4 +108,6 @@ abstract class ModificationApplyOperation implements StoreTreeNode<ModificationA
      */
     @Override
     public abstract Optional<ModificationApplyOperation> getChild(PathArgument child);
+
+    abstract void recursivelyVerifyStructure(NormalizedNode<?, ?> value);
 }