Reduce JSR305 proliferation
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / PingPongTransactionChain.java
index adcf8aaf382ba859df7d7788cae729a52f3da20d..af474c5c56c5370e9d6b2c7845e42a27d8984ea7 100644 (file)
@@ -7,9 +7,11 @@
  */
 package org.opendaylight.controller.md.sal.dom.broker.impl;
 
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Verify.verify;
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Verify;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.FutureCallback;
@@ -18,8 +20,8 @@ import java.util.AbstractMap.SimpleImmutableEntry;
 import java.util.Map.Entry;
 import java.util.concurrent.CancellationException;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import javax.annotation.Nonnull;
 import javax.annotation.concurrent.GuardedBy;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
@@ -97,7 +99,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain {
     private volatile PingPongTransaction inflightTx;
 
     PingPongTransactionChain(final DOMDataBroker broker, final TransactionChainListener listener) {
-        this.listener = Preconditions.checkNotNull(listener);
+        this.listener = requireNonNull(listener);
         this.delegate = broker.createTransactionChain(new TransactionChainListener() {
             @Override
             public void onTransactionChainFailed(final TransactionChain<?, ?> chain,
@@ -163,7 +165,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain {
     }
 
     private synchronized PingPongTransaction slowAllocateTransaction() {
-        Preconditions.checkState(shutdownTx == null, "Transaction chain %s has been shut down", this);
+        checkState(shutdownTx == null, "Transaction chain %s has been shut down", this);
 
         if (deadTx != null) {
             throw new IllegalStateException(
@@ -225,7 +227,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain {
      * @param tx Transaction which needs processing.
      */
     @GuardedBy("this")
-    private void processTransaction(@Nonnull final PingPongTransaction tx) {
+    private void processTransaction(final @NonNull PingPongTransaction tx) {
         if (failed) {
             LOG.debug("Cancelling transaction {}", tx);
             tx.getTransaction().cancel();
@@ -273,7 +275,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain {
      */
     private synchronized void processNextTransaction(final PingPongTransaction tx) {
         final boolean success = INFLIGHT_UPDATER.compareAndSet(this, tx, null);
-        Preconditions.checkState(success, "Completed transaction %s while %s was submitted", tx, inflightTx);
+        checkState(success, "Completed transaction %s while %s was submitted", tx, inflightTx);
 
         final PingPongTransaction nextTx = READY_UPDATER.getAndSet(this, null);
         if (nextTx != null) {
@@ -299,10 +301,10 @@ public final class PingPongTransactionChain implements DOMTransactionChain {
         processNextTransaction(tx);
     }
 
-    void readyTransaction(@Nonnull final PingPongTransaction tx) {
+    void readyTransaction(final @NonNull PingPongTransaction tx) {
         // First mark the transaction as not locked.
         final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null);
-        Preconditions.checkState(lockedMatch, "Attempted to submit transaction %s while we have %s", tx, lockedTx);
+        checkState(lockedMatch, "Attempted to submit transaction %s while we have %s", tx, lockedTx);
         LOG.debug("Transaction {} unlocked", tx);
 
         /*
@@ -310,7 +312,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain {
          * or a background transaction completion callback.
          */
         final boolean success = READY_UPDATER.compareAndSet(this, null, tx);
-        Preconditions.checkState(success, "Transaction %s collided on ready state", tx, readyTx);
+        checkState(success, "Transaction %s collided on ready state", tx, readyTx);
         LOG.debug("Transaction {} readied", tx);
 
         /*
@@ -338,7 +340,7 @@ public final class PingPongTransactionChain implements DOMTransactionChain {
     synchronized void cancelTransaction(final PingPongTransaction tx, final DOMDataReadWriteTransaction frontendTx) {
         // Attempt to unlock the operation.
         final boolean lockedMatch = LOCKED_UPDATER.compareAndSet(this, tx, null);
-        Verify.verify(lockedMatch, "Cancelling transaction %s collided with locked transaction %s", tx, lockedTx);
+        verify(lockedMatch, "Cancelling transaction %s collided with locked transaction %s", tx, lockedTx);
 
         // Cancel the backend transaction, so we do not end up leaking it.
         final boolean backendCancelled = tx.getTransaction().cancel();
@@ -374,12 +376,11 @@ public final class PingPongTransactionChain implements DOMTransactionChain {
     @Override
     public synchronized void close() {
         final PingPongTransaction notLocked = lockedTx;
-        Preconditions
-                .checkState(notLocked == null, "Attempted to close chain with outstanding transaction %s", notLocked);
+        checkState(notLocked == null, "Attempted to close chain with outstanding transaction %s", notLocked);
 
         // This is not reliable, but if we observe it to be null and the process has already completed,
         // the backend transaction chain will throw the appropriate error.
-        Preconditions.checkState(shutdownTx == null, "Attempted to close an already-closed chain");
+        checkState(shutdownTx == null, "Attempted to close an already-closed chain");
 
         // This may be a reaction to our failure callback, in that case the backend is already shutdown
         if (deadTx != null) {