Introduce DelegatingModificationApplyOperation
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / RootModificationApplyOperation.java
index 0c1d969b60dcb303798d6e7431a6e4111ff023dd..0372409b04c32c3442aee17ab68fc102d73e8a08 100644 (file)
@@ -7,13 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
-import java.util.Optional;
-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.spi.TreeNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
-
 /**
  * Represents a {@link ModificationApplyOperation} which is rooted at conceptual
  * top of data tree.
@@ -58,67 +51,30 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
  * update of schema and user actually writes data after schema update. During
  * update user did not invoked any operation.
  */
-abstract class RootModificationApplyOperation extends ModificationApplyOperation {
+abstract class RootModificationApplyOperation extends FullyDelegatedModificationApplyOperation {
 
-    @Override
-    public final Optional<ModificationApplyOperation> getChild(final PathArgument child) {
-        return getDelegate().getChild(child);
-    }
-
-    @Override
-    final void checkApplicable(final ModificationPath path, final NodeModification modification,
-            final Optional<TreeNode> current, final Version version) throws DataValidationFailedException {
-        getDelegate().checkApplicable(path, modification, current, version);
-    }
-
-    @Override
-    final Optional<TreeNode> apply(final ModifiedNode modification, final Optional<TreeNode> currentMeta,
-            final Version version) {
-        return getDelegate().apply(modification, currentMeta, version);
+    static RootModificationApplyOperation from(final ModificationApplyOperation resolver) {
+        if (resolver instanceof RootModificationApplyOperation) {
+            return ((RootModificationApplyOperation) resolver).snapshot();
+        }
+        return new NotUpgradableModificationApplyOperation(resolver);
     }
 
     @Override
     public final boolean equals(final Object obj) {
-        return getDelegate().equals(obj);
+        return delegate().equals(obj);
     }
 
     @Override
     public final int hashCode() {
-        return getDelegate().hashCode();
+        return delegate().hashCode();
     }
 
     @Override
     public final String toString() {
-        return getDelegate().toString();
-    }
-
-    @Override
-    final void verifyStructure(final NormalizedNode<?, ?> modification, final boolean verifyChildren) {
-        getDelegate().verifyStructure(modification, verifyChildren);
-    }
-
-    @Override
-    void recursivelyVerifyStructure(final NormalizedNode<?, ?> value) {
-        getDelegate().recursivelyVerifyStructure(value);
+        return delegate().toString();
     }
 
-    @Override
-    final ChildTrackingPolicy getChildPolicy() {
-        return getDelegate().getChildPolicy();
-    }
-
-    @Override
-    final void mergeIntoModifiedNode(final ModifiedNode node, final NormalizedNode<?, ?> value, final Version version) {
-        getDelegate().mergeIntoModifiedNode(node, value, version);
-    }
-
-    /**
-     * Return the underlying delegate.
-     *
-     * @return Underlying delegate.
-     */
-    abstract ModificationApplyOperation getDelegate();
-
     /**
      * Creates a snapshot from this modification, which may have separate
      * upgrade lifecycle and is not affected by upgrades.
@@ -141,11 +97,4 @@ abstract class RootModificationApplyOperation extends ModificationApplyOperation
      * {@link LatestOperationHolder#setCurrent(ModificationApplyOperation)}.
      */
     abstract void upgradeIfPossible();
-
-    static RootModificationApplyOperation from(final ModificationApplyOperation resolver) {
-        if (resolver instanceof RootModificationApplyOperation) {
-            return ((RootModificationApplyOperation) resolver).snapshot();
-        }
-        return new NotUpgradableModificationApplyOperation(resolver);
-    }
 }