Cleanup ShardRootModificationContext 19/60719/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 24 Jul 2017 12:10:51 +0000 (14:10 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 25 Jul 2017 22:57:39 +0000 (00:57 +0200)
Remove and unneeded cast and add Identifiable interface.

Change-Id: Ibd9217402055863461349f8071211a95b3b5e2ae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/ShardRootModificationContext.java

index 41bd1cef9933c621a0d73f1b6b7121a842790b67..11f03d993d4b722f4e63424812ff7fb980e5ad44 100644 (file)
@@ -10,16 +10,19 @@ package org.opendaylight.mdsal.dom.store.inmemory;
 
 import com.google.common.base.Preconditions;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.CursorAwareDataTreeSnapshot;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModificationCursor;
 
-class ShardRootModificationContext {
+// Non-final for mocking
+class ShardRootModificationContext implements Identifiable<DOMDataTreeIdentifier> {
 
     private final DOMDataTreeIdentifier identifier;
     private final CursorAwareDataTreeSnapshot snapshot;
+
     private CursorAwareDataTreeModification modification = null;
     private DataTreeModificationCursorAdaptor cursor = null;
 
@@ -29,6 +32,7 @@ class ShardRootModificationContext {
         this.snapshot = Preconditions.checkNotNull(snapshot);
     }
 
+    @Override
     public DOMDataTreeIdentifier getIdentifier() {
         return identifier;
     }
@@ -36,12 +40,11 @@ class ShardRootModificationContext {
     DataTreeModificationCursorAdaptor cursor() {
         if (cursor == null) {
             if (modification == null) {
-                modification = (CursorAwareDataTreeModification) snapshot.newModification();
+                modification = snapshot.newModification();
             }
 
             // FIXME: Should there be non-root path?
-            DataTreeModificationCursor dataTreeCursor =
-                    modification.createCursor(YangInstanceIdentifier.EMPTY);
+            DataTreeModificationCursor dataTreeCursor = modification.createCursor(YangInstanceIdentifier.EMPTY);
             cursor = DataTreeModificationCursorAdaptor.of(dataTreeCursor);
         }
         return cursor;