Migrate mdsal-common-api to JDT annotations 41/76741/11
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 8 Oct 2018 10:54:54 +0000 (12:54 +0200)
committerJie Han <han.jie@zte.com.cn>
Tue, 9 Oct 2018 01:45:09 +0000 (01:45 +0000)
This removes the use of javax.annotation nullable annotations
to remove import-package. Also improve APIs by annotating additional
elements with @NonNull and reusing FluentFutures, which are more JDT
friendly.

JIRA: MDSAL-373
Change-Id: I9cb82bcb5bd755dbb544efeefeb9a0ebec3cb69c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
common/mdsal-common-api/src/main/java/org/opendaylight/mdsal/common/api/PostCanCommitStep.java
common/mdsal-common-api/src/main/java/org/opendaylight/mdsal/common/api/PostPreCommitStep.java
common/mdsal-common-api/src/main/java/org/opendaylight/mdsal/common/api/ThreePhaseCommitStep.java
common/mdsal-common-api/src/test/java/org/opendaylight/mdsal/common/api/DataValidationFailedExceptionTest.java

index 7f3287fa866ee36764553e779756a49eb5fdff59..c9eadcff93e3fdd72db06f08f78780fc4860f5b4 100644 (file)
@@ -10,18 +10,16 @@ package org.opendaylight.mdsal.common.api;
 import com.google.common.annotations.Beta;
 import com.google.common.util.concurrent.FluentFuture;
 import com.google.common.util.concurrent.ListenableFuture;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 
 /**
  * User implementation of steps following can-commit in three phase protocol.
  * If no additional visibility into transaction and data being aborted or committed is needed, use
  * {@link #NOOP} implementation.
- *
  */
 @Beta
 public interface PostCanCommitStep extends ThreePhaseCommitStep {
-
     /**
      * No-op implementation of abort, pre-commit and commit steps.
      * This implementation should be used if user logic does only validation of data and does not
@@ -40,7 +38,7 @@ public interface PostCanCommitStep extends ThreePhaseCommitStep {
         }
     };
 
-    FluentFuture<PostCanCommitStep> NOOP_SUCCESSFUL_FUTURE = FluentFutures.immediateFluentFuture(NOOP);
+    @NonNull FluentFuture<PostCanCommitStep> NOOP_SUCCESSFUL_FUTURE = FluentFutures.immediateFluentFuture(NOOP);
 
     /**
      * Initiates a pre-commit of associated request
@@ -49,9 +47,6 @@ public interface PostCanCommitStep extends ThreePhaseCommitStep {
      * object.
      *
      * @return Future which is completed once pre-commit phase for this request is finished.
-     *
      */
-    @Nonnull
-    ListenableFuture<? extends PostPreCommitStep> preCommit();
-
+    @NonNull ListenableFuture<? extends PostPreCommitStep> preCommit();
 }
index d3a7760d9d667e3399d35d47ac96e21d0106b7e9..d89a74197850ae8c0586029483eba3a2b1a2089b 100644 (file)
@@ -8,16 +8,15 @@
 package org.opendaylight.mdsal.common.api;
 
 import com.google.common.annotations.Beta;
-import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 
 /**
  * User implementation of steps following pre-commit from Three-Phase Protocol.
- *
  */
 @Beta
 public interface PostPreCommitStep extends ThreePhaseCommitStep {
-
     /**
      * No-op implementation of {@link #abort()} and {@link #commit()} method, which always success
      * calls.
@@ -38,9 +37,9 @@ public interface PostPreCommitStep extends ThreePhaseCommitStep {
         }
     };
 
-    ListenableFuture<?> NOOP_COMMIT_FUTURE = Futures.immediateFuture(null);
+    @NonNull ListenableFuture<?> NOOP_COMMIT_FUTURE = FluentFutures.immediateNullFluentFuture();
 
-    ListenableFuture<? extends PostPreCommitStep> NOOP_FUTURE = Futures.immediateFuture(NOOP);
+    @NonNull ListenableFuture<? extends PostPreCommitStep> NOOP_FUTURE = FluentFutures.immediateFluentFuture(NOOP);
 
     /**
      * Commits cohort transaction.
@@ -51,6 +50,5 @@ public interface PostPreCommitStep extends ThreePhaseCommitStep {
      *
      * @return Listenable Future which will complete once commit is finished.
      */
-    ListenableFuture<?> commit();
-
+    @NonNull ListenableFuture<?> commit();
 }
index 3fd8aa8f57534bab1682994e6a1ba242bea01d9f..f8e14e64fca2f3ae953f09f05ad8cb31a80629f8 100644 (file)
@@ -5,13 +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.common.api;
 
 import com.google.common.annotations.Beta;
-import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.util.concurrent.FluentFutures;
 
 /**
  * Common interface for implementing three-phase commit steps.
@@ -21,8 +20,7 @@ import javax.annotation.Nonnull;
  */
 @Beta
 public interface ThreePhaseCommitStep {
-
-    ListenableFuture<?> NOOP_ABORT_FUTURE = Futures.immediateFuture(null);
+    @NonNull ListenableFuture<?> NOOP_ABORT_FUTURE = FluentFutures.immediateNullFluentFuture();
 
     /**
      * Invoked on transaction aborted.
@@ -33,6 +31,5 @@ public interface ThreePhaseCommitStep {
      *
      * @return ListenableFuture which will complete once abort is completed.
      */
-    @Nonnull
-    ListenableFuture<?> abort();
+    @NonNull ListenableFuture<?> abort();
 }
index fcff681a3ab291be83f62f0694b01f4e15eeb401..0d0d99e7300dc022f5c211bbd0a1bf3dbfa121c1 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.mdsal.common.api;
 
 import static org.junit.Assert.assertEquals;
 
-import javax.annotation.Nonnull;
 import org.junit.Test;
 import org.opendaylight.yangtools.concepts.Path;
 
@@ -29,8 +28,8 @@ public class DataValidationFailedExceptionTest {
 
     private final class TestClass implements Path<TestClass> {
         @Override
-        public boolean contains(@Nonnull final TestClass other) {
+        public boolean contains(final TestClass other) {
             return false;
         }
     }
-}
\ No newline at end of file
+}