Clean up checkSealed()
[yangtools.git] / data / yang-data-tree-ri / src / main / java / org / opendaylight / yangtools / yang / data / tree / impl / InMemoryDataTreeModification.java
index 365f26c82efd8d41cd0051ad00012aab995aa7fd..a8da8e79a0fa8d13279a8717aa694149c8193b60 100644 (file)
@@ -89,22 +89,21 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
 
     @Override
     public void write(final YangInstanceIdentifier path, final NormalizedNode data) {
-        checkSealed();
+        checkOpen();
         checkIdentifierReferencesData(path, data);
         resolveModificationFor(path).write(data);
     }
 
     @Override
     public void merge(final YangInstanceIdentifier path, final NormalizedNode data) {
-        checkSealed();
+        checkOpen();
         checkIdentifierReferencesData(path, data);
         resolveModificationFor(path).merge(data, version);
     }
 
     @Override
     public void delete(final YangInstanceIdentifier path) {
-        checkSealed();
-
+        checkOpen();
         resolveModificationFor(path).delete();
     }
 
@@ -191,10 +190,6 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
         return OperationWithModification.from(operation, modification);
     }
 
-    private void checkSealed() {
-        checkState(!isSealed(), "Data Tree is sealed. No further modifications allowed.");
-    }
-
     @Override
     public String toString() {
         return "MutableDataTree [modification=" + rootNode + "]";
@@ -231,6 +226,12 @@ final class InMemoryDataTreeModification extends AbstractCursorAware implements
         return (int) SEALED.getAcquire(this) != 0;
     }
 
+    private void checkOpen() {
+        if (isSealed()) {
+            throw new IllegalStateException("Data Tree is sealed. No further modifications allowed.");
+        }
+    }
+
     private static void applyChildren(final DataTreeModificationCursor cursor, final ModifiedNode node) {
         if (!node.isEmpty()) {
             cursor.enter(node.getIdentifier());