Refactor ModificationApplyOperation
[yangtools.git] / data / yang-data-tree-ri / src / main / java / org / opendaylight / yangtools / yang / data / tree / impl / InMemoryDataTreeModification.java
index df3da508a0a894e24ba5e6d8aef808ed0b55ce07..56f426fd4a92dbd07ce2a476aeda90ca330769ec 100644 (file)
@@ -143,7 +143,7 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
         }
 
         try {
-            return resolveModificationStrategy(path).apply(modification, modification.getOriginal(), version);
+            return resolveModificationStrategy(path).apply(modification, modification.original(), version);
         } catch (Exception e) {
             LOG.error("Could not create snapshot for {}:{}", path, modification, e);
             throw e;
@@ -213,12 +213,11 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
          * have same version each time this method is called.
          */
         final var originalSnapshotRoot = snapshot.getRootNode();
-        final var tempRoot = getStrategy().apply(rootNode, Optional.of(originalSnapshotRoot), version);
-        checkState(tempRoot.isPresent(), "Data tree root is not present, possibly removed by previous modification");
-
-        final var tempTree = new InMemoryDataTreeSnapshot(snapshot.getEffectiveModelContext(), tempRoot.orElseThrow(),
-            strategyTree);
-        return tempTree.newModification();
+        return new InMemoryDataTreeSnapshot(snapshot.getEffectiveModelContext(),
+            getStrategy().apply(rootNode, originalSnapshotRoot, version)
+                .orElseThrow(() -> new IllegalStateException(
+                    "Data tree root is not present, possibly removed by previous modification")), strategyTree)
+            .newModification();
     }
 
     Version getVersion() {