Update javadoc links
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / data / AsyncWriteTransaction.java
index 57fbf890d42e8bdc58df9488e7234c82c5b37003..70789ccb1481c36e8179999d341a0bdddecd47b8 100644 (file)
@@ -11,10 +11,11 @@ import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
-import javax.annotation.CheckReturnValue;
 import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
 
 /**
  * Write transaction provides mutation capabilities for a data tree.
@@ -157,8 +158,7 @@ public interface AsyncWriteTransaction<P extends Path<P>, D> extends AsyncTransa
      * ({@link AsyncConfigurationCommitHandler}) if the transaction changes the data tree.
      *
      * <p>
-     * The effects of a successful commit of data depends on data change listeners
-     * ({@link AsyncDataChangeListener}) and commit participants
+     * The effects of a successful commit of data depends on data tree change listeners and commit participants
      * ({@link AsyncConfigurationCommitHandler}) that are registered with the data broker.
      *
      * <h3>Example usage:</h3>
@@ -338,8 +338,10 @@ public interface AsyncWriteTransaction<P extends Path<P>, D> extends AsyncTransa
      * @deprecated Use {@link #commit()} instead.
      */
     @Deprecated
-    @CheckReturnValue
-    CheckedFuture<Void,TransactionCommitFailedException> submit();
+    default CheckedFuture<Void, TransactionCommitFailedException> submit() {
+        return MappingCheckedFuture.create(commit().transform(ignored -> null, MoreExecutors.directExecutor()),
+                SUBMIT_EXCEPTION_MAPPER);
+    }
 
     /**
      * Submits this transaction to be asynchronously applied to update the logical data tree. The returned
@@ -370,9 +372,17 @@ public interface AsyncWriteTransaction<P extends Path<P>, D> extends AsyncTransa
      *         {@link TransactionCommitFailedException} or an exception derived from TransactionCommitFailedException.
      * @throws IllegalStateException if the transaction is already committed or was canceled.
      */
-    @CheckReturnValue
-    default @NonNull FluentFuture<? extends @NonNull CommitInfo> commit() {
-        return FluentFuture.from(submit()).transformAsync(ignored -> CommitInfo.emptyFluentFuture(),
-            MoreExecutors.directExecutor());
-    }
+    @NonNull FluentFuture<? extends @NonNull CommitInfo> commit();
+
+    /**
+     * This only exists for reuse by the deprecated {@link #submit} method and is not intended for general use.
+     */
+    @Deprecated
+    ExceptionMapper<TransactionCommitFailedException> SUBMIT_EXCEPTION_MAPPER =
+        new ExceptionMapper<TransactionCommitFailedException>("submit", TransactionCommitFailedException.class) {
+            @Override
+            protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) {
+                return new TransactionCommitFailedException(message, cause);
+            }
+        };
 }