Convert MinMaxElementsValidation to ModificationApplyOperation
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / ModifiedNode.java
index 5456380cc51609730143f0496b65824a9b8ee122..b4bf65fc0dbf5f38a3a25baa5d53558fd86d8ae9 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
+import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
 import java.util.Collection;
@@ -67,9 +68,9 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
     private TreeNode writtenOriginal;
 
     // Internal cache for TreeNodes created as part of validation
-    private SchemaAwareApplyOperation validatedOp;
+    private ModificationApplyOperation validatedOp;
     private Optional<TreeNode> validatedCurrent;
-    private TreeNode validatedNode;
+    private Optional<TreeNode> validatedNode;
 
     private ModifiedNode(final PathArgument identifier, final Optional<TreeNode> original,
             final ChildTrackingPolicy childPolicy) {
@@ -101,8 +102,9 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
      *
      * @return Currently-written value
      */
+    @Nonnull
     NormalizedNode<?, ?> getWrittenValue() {
-        return value;
+        return verifyNotNull(value);
     }
 
     /**
@@ -249,10 +251,10 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
     /**
      * Records a write for associated node.
      *
-     * @param value new value
+     * @param newValue new value
      */
-    void write(final NormalizedNode<?, ?> value) {
-        updateValue(LogicalOperation.WRITE, value);
+    void write(final NormalizedNode<?, ?> newValue) {
+        updateValue(LogicalOperation.WRITE, newValue);
         children.clear();
     }
 
@@ -323,10 +325,10 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
      * Update this node's value and operation type without disturbing any of its child modifications.
      *
      * @param type New operation type
-     * @param value New node value
+     * @param newValue New node value
      */
-    void updateValue(final LogicalOperation type, final NormalizedNode<?, ?> value) {
-        this.value = requireNonNull(value);
+    void updateValue(final LogicalOperation type, final NormalizedNode<?, ?> newValue) {
+        this.value = requireNonNull(newValue);
         updateOperationType(type);
     }
 
@@ -346,13 +348,14 @@ final class ModifiedNode extends NodeModification implements StoreTreeNode<Modif
         return new ModifiedNode(metadataTree.getIdentifier(), Optional.of(metadataTree), childPolicy);
     }
 
-    void setValidatedNode(final SchemaAwareApplyOperation op, final Optional<TreeNode> current, final TreeNode node) {
+    void setValidatedNode(final ModificationApplyOperation op, final Optional<TreeNode> current,
+            final Optional<TreeNode> node) {
         this.validatedOp = requireNonNull(op);
         this.validatedCurrent = requireNonNull(current);
         this.validatedNode = requireNonNull(node);
     }
 
-    TreeNode getValidatedNode(final SchemaAwareApplyOperation op, final Optional<TreeNode> current) {
+    Optional<TreeNode> getValidatedNode(final ModificationApplyOperation op, final Optional<TreeNode> current) {
         return op.equals(validatedOp) && current.equals(validatedCurrent) ? validatedNode : null;
     }
 }