Refactor ModificationApplyOperation
[yangtools.git] / data / yang-data-tree-ri / src / main / java / org / opendaylight / yangtools / yang / data / tree / impl / AbstractValidation.java
index 38907df628e74f583565ad9a65e83ad1883605df..e69b959a7d324bf1be8391e7aea6ebdc4bf17cc0 100644 (file)
@@ -61,31 +61,31 @@ abstract sealed class AbstractValidation extends ModificationApplyOperation
     }
 
     @Override
-    final Optional<? extends TreeNode> apply(final ModifiedNode modification,
-            final Optional<? extends TreeNode> storeMeta, final Version version) {
-        var validated = modification.validatedNode(this, storeMeta);
+    final Optional<? extends TreeNode> apply(final ModifiedNode modification, final TreeNode currentMeta,
+            final Version version) {
+        var validated = modification.validatedNode(this, currentMeta);
         if (validated != null) {
             return validated.toOptional();
         }
 
         // This might also mean the delegate is maintaining validation
         if (delegate instanceof AbstractValidation) {
-            validated = modification.validatedNode(delegate, storeMeta);
+            validated = modification.validatedNode(delegate, currentMeta);
             if (validated != null) {
                 return validated.toOptional();
             }
         }
 
         // Deal with the result moving on us
-        final var ret = delegate.apply(modification, storeMeta, version);
+        final var ret = delegate.apply(modification, currentMeta, version);
         ret.ifPresent(meta -> enforceOnData(meta.getData()));
         return ret;
     }
 
     @Override
     final void checkApplicable(final ModificationPath path, final NodeModification modification,
-            final Optional<? extends TreeNode> current, final Version version) throws DataValidationFailedException {
-        delegate.checkApplicable(path, modification, current, version);
+            final TreeNode currentMeta, final Version version) throws DataValidationFailedException {
+        delegate.checkApplicable(path, modification, currentMeta, version);
         if (!(modification instanceof ModifiedNode modified)) {
             // FIXME: 7.0.0: turn this into a verify?
             LOG.debug("Could not validate {}, does not implement expected class {}", modification, ModifiedNode.class);
@@ -93,13 +93,13 @@ abstract sealed class AbstractValidation extends ModificationApplyOperation
         }
 
         if (delegate instanceof AbstractValidation) {
-            checkApplicable(path, verifyNotNull(modified.validatedNode(delegate, current)).toOptional());
+            checkApplicable(path, verifyNotNull(modified.validatedNode(delegate, currentMeta)).toOptional());
             return;
         }
 
         // We need to actually perform the operation to deal with merge in a sane manner. We know the modification
         // is immutable, so the result of validation will probably not change. Note we should not be checking number
-        final Optional<? extends TreeNode> applied = delegate.apply(modified, current, version);
+        final var applied = delegate.apply(modified, currentMeta, version);
         checkApplicable(path, applied);
 
         // Everything passed. We now have a snapshot of the result node, it would be too bad if we just threw it out.
@@ -108,7 +108,7 @@ abstract sealed class AbstractValidation extends ModificationApplyOperation
         // - the effective model context (therefore, the fact this object is associated with the modification)
         //
         // So let's stash the result. We will pick it up during apply operation.
-        modified.setValidatedNode(this, current, applied);
+        modified.setValidatedNode(this, currentMeta, applied);
     }
 
     private void checkApplicable(final ModificationPath path, final Optional<? extends TreeNode> applied)