Split out AbstractValidation
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / ModificationApplyOperation.java
index 0f750c9d70c5485cd6489f873849f802f284c535..9b402a64d79a5296ffdcfa2e0bf48327545d6065 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
 import java.util.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;
@@ -55,29 +56,41 @@ abstract class ModificationApplyOperation implements StoreTreeNode<ModificationA
      *             If it is not possible to apply Operation on provided Metadata
      *             node
      */
-    abstract Optional<TreeNode> apply(ModifiedNode modification, Optional<TreeNode> storeMeta, Version version);
+    abstract Optional<? extends TreeNode> apply(ModifiedNode modification, Optional<? extends TreeNode> storeMeta,
+            Version version);
 
     /**
      * Checks if provided node modification could be applied to current metadata node.
      *
+     * @param path Path to modification
      * @param modification Modification
      * @param current Metadata Node to which modification should be applied
      * @param version Metadata version
      * @throws DataValidationFailedException if the modification is not applicable
      */
-    abstract void checkApplicable(YangInstanceIdentifier path, NodeModification modification,
-            Optional<TreeNode> current, Version version) throws DataValidationFailedException;
+    abstract void checkApplicable(ModificationPath path, NodeModification modification,
+            Optional<? extends TreeNode> current, Version version) throws DataValidationFailedException;
 
     /**
-     * Performs structural verification of NodeModification, such as writen values / types uses
-     * right structural elements.
+     * Performs a quick structural verification of NodeModification, such as written 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);
+    abstract void quickVerifyStructure(NormalizedNode<?, ?> modification);
+
+    /**
+     * Performs a full structural verification of NodeModification, such as written values / types uses right
+     * structural elements. Unlike {@link #quickVerifyStructure(NormalizedNode)} this includes recursively checking
+     * children, too.
+     *
+     * @param modification data to be verified.
+     * @throws IllegalArgumentException If provided NodeModification does not adhere to the
+     *         structure.
+     */
+    abstract void fullVerifyStructure(NormalizedNode<?, ?> modification);
 
     /**
      * Return the tracking policy for this node's children.
@@ -100,11 +113,18 @@ abstract class ModificationApplyOperation implements StoreTreeNode<ModificationA
     /**
      * Returns a suboperation for specified tree node.
      *
-     * @return Reference to suboperation for specified tree node, {@link Optional#absent()}
+     * @return Reference to suboperation for specified tree node, {@link Optional#empty()}
      *         if suboperation is not supported for specified tree node.
      */
     @Override
     public abstract Optional<ModificationApplyOperation> getChild(PathArgument child);
 
     abstract void recursivelyVerifyStructure(NormalizedNode<?, ?> value);
+
+    abstract ToStringHelper addToStringAttributes(ToStringHelper helper);
+
+    @Override
+    public final String toString() {
+        return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
+    }
 }