Do not generate 'isFoo()' methods
[mdsal.git] / dom / mdsal-dom-inmemory-datastore / src / main / java / org / opendaylight / mdsal / dom / store / inmemory / InmemoryDOMDataTreeShardWriteTransaction.java
index 1849dc317f32265a7c6aa8ca908104f46b299681..5fe19519798c2993081a80a09743f80a326a86e6 100644 (file)
@@ -5,11 +5,12 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.mdsal.dom.store.inmemory;
 
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.CheckedFuture;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
 import java.util.ArrayList;
@@ -17,11 +18,11 @@ 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;
 import org.opendaylight.mdsal.dom.spi.shard.ForeignShardModificationContext;
+import org.opendaylight.mdsal.dom.spi.shard.ForeignShardThreePhaseCommitCohort;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
 import org.opendaylight.yangtools.concepts.Identifiable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -103,9 +104,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;
@@ -125,8 +126,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
 
     void delete(final YangInstanceIdentifier path) {
         final YangInstanceIdentifier relativePath = toRelative(path);
-        Preconditions.checkArgument(!YangInstanceIdentifier.EMPTY.equals(relativePath),
-                "Deletion of shard root is not allowed");
+        checkArgument(!relativePath.isEmpty(), "Deletion of shard root is not allowed");
         SimpleCursorOperation.DELETE.apply(getCursor(), relativePath, null);
     }
 
@@ -141,21 +141,13 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
     private YangInstanceIdentifier toRelative(final YangInstanceIdentifier path) {
         final Optional<YangInstanceIdentifier> relative =
                 path.relativeTo(modification.getPrefix().getRootIdentifier());
-        Preconditions.checkArgument(relative.isPresent());
+        checkArgument(relative.isPresent());
         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.");
+        checkState(!finished, "Attempting to close an already finished transaction.");
         modification.closeTransactions();
         if (cursor != null) {
             cursor.close();
@@ -165,7 +157,7 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
     }
 
     void cursorClosed() {
-        Preconditions.checkNotNull(cursor);
+        requireNonNull(cursor);
         modification.closeCursor();
         cursor = null;
     }
@@ -176,9 +168,9 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
 
     @Override
     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.");
+        checkState(!finished, "Attempting to ready an already finished transaction.");
+        checkState(cursor == null, "Attempting to ready a transaction that has an open cursor.");
+        requireNonNull(modification, "Attempting to ready an empty transaction.");
 
         LOG.debug("Readying open transaction on shard {}", modification.getPrefix());
         rootModification = modification.seal();
@@ -197,8 +189,8 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
     public ListenableFuture<Void> submit() {
         LOG.debug("Submitting open transaction on shard {}", modification.getPrefix());
 
-        Preconditions.checkNotNull(cohorts);
-        Preconditions.checkState(!cohorts.isEmpty(), "Transaction was not readied yet.");
+        requireNonNull(cohorts);
+        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;
     }
 
@@ -232,8 +224,8 @@ class InmemoryDOMDataTreeShardWriteTransaction implements DOMDataTreeShardWriteT
 
     @Override
     public DOMDataTreeWriteCursor createCursor(final DOMDataTreeIdentifier prefix) {
-        Preconditions.checkState(!finished, "Transaction is finished/closed already.");
-        Preconditions.checkState(cursor == null, "Previous cursor wasn't closed");
+        checkState(!finished, "Transaction is finished/closed already.");
+        checkState(cursor == null, "Previous cursor wasn't closed");
         final YangInstanceIdentifier relativePath = toRelative(prefix.getRootIdentifier());
         final DOMDataTreeWriteCursor ret = getCursor();
         ret.enter(relativePath.getPathArguments());