Minor sal-distributed-datastore cleanups
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / ClientTransaction.java
index 5a28e692aaadfb4f04a9ea41f88690df6fe6b2ee..ce051ab44be3c407cf23415a0e6eb1705e709e30 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.controller.cluster.databroker.actors.dds;
 
+import static com.google.common.base.Preconditions.checkState;
+
 import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
 import com.google.common.util.concurrent.FluentFuture;
 import java.util.Collection;
 import java.util.Optional;
@@ -66,7 +66,7 @@ public class ClientTransaction extends AbstractClientHandle<AbstractProxyTransac
 
     @Deprecated(forRemoval = true)
     public DOMDataTreeWriteCursor openCursor() {
-        Preconditions.checkState(cursor == null, "Transaction %s has open cursor", getIdentifier());
+        checkState(cursor == null, "Transaction %s has open cursor", getIdentifier());
         cursor = new ClientTransactionCursor(this);
         return cursor;
     }
@@ -93,7 +93,7 @@ public class ClientTransaction extends AbstractClientHandle<AbstractProxyTransac
 
     public DOMStoreThreePhaseCommitCohort ready() {
         final Collection<AbstractProxyTransaction> toReady = ensureClosed();
-        Preconditions.checkState(toReady != null, "Attempted to submit a closed transaction %s", this);
+        checkState(toReady != null, "Attempted to submit a closed transaction %s", this);
 
         toReady.forEach(AbstractProxyTransaction::seal);
         final AbstractTransactionCommitCohort cohort;
@@ -102,8 +102,7 @@ public class ClientTransaction extends AbstractClientHandle<AbstractProxyTransac
                 cohort = new EmptyTransactionCommitCohort(parent(), getIdentifier());
                 break;
             case 1:
-                cohort = new DirectTransactionCommitCohort(parent(), getIdentifier(),
-                    Iterables.getOnlyElement(toReady));
+                cohort = new DirectTransactionCommitCohort(parent(), getIdentifier(), toReady.iterator().next());
                 break;
             default:
                 cohort = new ClientTransactionCommitCohort(parent(), getIdentifier(), toReady);