Check registration being closed
[mdsal.git] / dom / mdsal-dom-inmemory-datastore / src / main / java / org / opendaylight / mdsal / dom / store / inmemory / InmemoryDOMDataTreeShardWriteTransaction.java
index 1849dc317f32265a7c6aa8ca908104f46b299681..3472d9c69f5956b73aa19add0dc34931fe0da874 100644 (file)
@@ -8,8 +8,9 @@
 
 package org.opendaylight.mdsal.dom.store.inmemory;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import java.util.ArrayList;
@@ -17,7 +18,6 @@ import java.util.Iterator;
 import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.concurrent.atomic.AtomicLong;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
 import org.opendaylight.mdsal.dom.spi.shard.DOMDataTreeShardWriteTransaction;
@@ -103,9 +103,9 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
                                              final InMemoryDOMDataTreeShardChangePublisher changePublisher,
                                              final ListeningExecutorService executor) {
         this.producer = producer;
-        this.modification = Preconditions.checkNotNull(root);
-        this.rootShardDataTree = Preconditions.checkNotNull(rootShardDataTree);
-        this.changePublisher = Preconditions.checkNotNull(changePublisher);
+        this.modification = requireNonNull(root);
+        this.rootShardDataTree = requireNonNull(rootShardDataTree);
+        this.changePublisher = requireNonNull(changePublisher);
         this.identifier = "INMEMORY-SHARD-TX-" + COUNTER.getAndIncrement();
         LOG.debug("Shard transaction{} created", identifier);
         this.executor = executor;
@@ -145,14 +145,6 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
         return relative.get();
     }
 
-    public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
-        throw new UnsupportedOperationException("Not implemented yet");
-    }
-
-    public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
-        throw new UnsupportedOperationException("Not implemented yet");
-    }
-
     @Override
     public void close() {
         Preconditions.checkState(!finished, "Attempting to close an already finished transaction.");
@@ -165,7 +157,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
     }
 
     void cursorClosed() {
-        Preconditions.checkNotNull(cursor);
+        requireNonNull(cursor);
         modification.closeCursor();
         cursor = null;
     }
@@ -178,7 +170,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
     public void ready() {
         Preconditions.checkState(!finished, "Attempting to ready an already finished transaction.");
         Preconditions.checkState(cursor == null, "Attempting to ready a transaction that has an open cursor.");
-        Preconditions.checkNotNull(modification, "Attempting to ready an empty transaction.");
+        requireNonNull(modification, "Attempting to ready an empty transaction.");
 
         LOG.debug("Readying open transaction on shard {}", modification.getPrefix());
         rootModification = modification.seal();
@@ -197,7 +189,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
     public ListenableFuture<Void> submit() {
         LOG.debug("Submitting open transaction on shard {}", modification.getPrefix());
 
-        Preconditions.checkNotNull(cohorts);
+        requireNonNull(cohorts);
         Preconditions.checkState(!cohorts.isEmpty(), "Transaction was not readied yet.");
 
         return executor.submit(new ShardSubmitCoordinationTask(modification.getPrefix(), cohorts, this));
@@ -222,7 +214,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
     }
 
     DataTreeModification getRootModification() {
-        Preconditions.checkNotNull(rootModification, "Transaction wasn't sealed yet");
+        requireNonNull(rootModification, "Transaction wasn't sealed yet");
         return rootModification;
     }