Migrate mdsal-singleton-dom-impl to JDT annotations 42/76742/11
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 8 Oct 2018 10:59:25 +0000 (12:59 +0200)
committerJie Han <han.jie@zte.com.cn>
Tue, 9 Oct 2018 06:44:27 +0000 (06:44 +0000)
This removes the use of javax.annotation nullable annotations
to remove import-package.

JIRA: MDSAL-373
Change-Id: I6b0683321f0f499383fb36e9658e9ba643f82b92
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/AbstractClusterSingletonServiceProviderImpl.java
singleton-service/mdsal-singleton-dom-impl/src/main/java/org/opendaylight/mdsal/singleton/dom/impl/ClusterSingletonServiceGroupImpl.java
singleton-service/mdsal-singleton-dom-impl/src/test/java/org/opendaylight/mdsal/singleton/dom/impl/util/TestEntity.java

index ab0a1ba4db86aa8eeab1447d16e8e406b8522d79..1f1f2891fab243f58cea28760280576746d3e6f6 100644 (file)
@@ -5,16 +5,15 @@
  * 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.singleton.dom.impl;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Verify.verify;
 import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
-import com.google.common.base.Verify;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -23,8 +22,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
 import org.opendaylight.mdsal.eos.common.api.GenericEntity;
 import org.opendaylight.mdsal.eos.common.api.GenericEntityOwnershipChange;
@@ -77,8 +75,8 @@ public abstract class AbstractClusterSingletonServiceProviderImpl<P extends Path
      *
      * @param entityOwnershipService relevant EOS
      */
-    protected AbstractClusterSingletonServiceProviderImpl(@Nonnull final S entityOwnershipService) {
-        this.entityOwnershipService = Preconditions.checkNotNull(entityOwnershipService);
+    protected AbstractClusterSingletonServiceProviderImpl(final @NonNull S entityOwnershipService) {
+        this.entityOwnershipService = requireNonNull(entityOwnershipService);
     }
 
     /**
@@ -92,12 +90,12 @@ public abstract class AbstractClusterSingletonServiceProviderImpl<P extends Path
 
     @Override
     public final synchronized ClusterSingletonServiceRegistration registerClusterSingletonService(
-            @CheckForNull final ClusterSingletonService service) {
+            final ClusterSingletonService service) {
         LOG.debug("Call registrationService {} method for ClusterSingletonService Provider {}", service, this);
 
         final String serviceIdentifier = service.getIdentifier().getValue();
-        Preconditions.checkArgument(!Strings.isNullOrEmpty(serviceIdentifier),
-                "ClusterSingletonService identifier may not be null nor empty");
+        checkArgument(!Strings.isNullOrEmpty(serviceIdentifier),
+            "ClusterSingletonService identifier may not be null nor empty");
 
         final ClusterSingletonServiceGroup<P, E, C> serviceGroup;
         ClusterSingletonServiceGroup<P, E, C> existing = serviceGroupMap.get(serviceIdentifier);
@@ -186,7 +184,7 @@ public abstract class AbstractClusterSingletonServiceProviderImpl<P extends Path
 
         // Placeholder is being retired, we are reusing its services as the seed for the group.
         final ClusterSingletonServiceGroup<P, E, C> group = createGroup(identifier, services);
-        Verify.verify(serviceGroupMap.replace(identifier, placeHolder, group));
+        verify(serviceGroupMap.replace(identifier, placeHolder, group));
         placeHolder.setSuccessor(group);
         LOG.debug("Service group upgraded from {} to {}", placeHolder, group);
 
index 7570a4bbfeb3e08a19078c31af97eec5e5905db5..b91bb0d9b627c3e12852395ac499acc1f4e04d26 100644 (file)
@@ -31,7 +31,6 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 import java.util.concurrent.atomic.AtomicReference;
-import javax.annotation.CheckReturnValue;
 import javax.annotation.concurrent.GuardedBy;
 import javax.annotation.concurrent.ThreadSafe;
 import org.eclipse.jdt.annotation.NonNull;
@@ -49,7 +48,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Implementation of {@link ClusterSingletonServiceGroup} on top of the Entitiy Ownership Service. Since EOS is atomic
+ * Implementation of {@link ClusterSingletonServiceGroup} on top of the Entity Ownership Service. Since EOS is atomic
  * in its operation and singleton services incur startup and most notably cleanup, we need to do something smart here.
  *
  * <p>
@@ -280,7 +279,6 @@ final class ClusterSingletonServiceGroupImpl<P extends Path<P>, E extends Generi
         reconcileState();
     }
 
-    @CheckReturnValue
     @Override
     ListenableFuture<?> unregisterService(final ClusterSingletonServiceRegistration reg) {
         final ClusterSingletonService service = reg.getInstance();
index 51d2d880ebef2c2aa7213dc72d636f6559fb335f..4367ccc6b89decc68764b7f04c48d363df5b11a0 100644 (file)
@@ -5,10 +5,9 @@
  * 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.singleton.dom.impl.util;
 
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.eos.common.api.GenericEntity;
 import org.opendaylight.yangtools.yang.common.QName;
 
@@ -27,7 +26,7 @@ public class TestEntity extends GenericEntity<TestInstanceIdentifier> {
      * @param type the entity type
      * @param id the entity id.
      */
-    public TestEntity(@Nonnull final String type, @Nonnull final TestInstanceIdentifier id) {
+    public TestEntity(final @NonNull String type, final @NonNull TestInstanceIdentifier id) {
         super(type, id);
     }
 
@@ -38,7 +37,7 @@ public class TestEntity extends GenericEntity<TestInstanceIdentifier> {
      * @param type the type of the entity
      * @param entityName the name of the entity used to construct a general-entity YangInstanceIdentifier
      */
-    public TestEntity(@Nonnull final String type, @Nonnull final String entityName) {
+    public TestEntity(final @NonNull String type, final @NonNull String entityName) {
         super(type, new TestInstanceIdentifier(entityName));
     }
 }