Enforce RegisterListenerLocal arguments 89/82989/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 10 Jul 2019 09:59:42 +0000 (11:59 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 16 Jul 2019 09:14:06 +0000 (09:14 +0000)
The fields need to be initialized to non-null, make sure the object
does that (instead of its users).

Change-Id: I545421167bd33e06ea7221a0fbcc136083bfc80d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/messages/RegisterListenerLocal.java

index 2dab37c..8eb69da 100644 (file)
@@ -166,9 +166,6 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ
     @Override
     public DOMEntityOwnershipListenerRegistration registerListener(final String entityType,
             final DOMEntityOwnershipListener listener) {
-        Preconditions.checkNotNull(entityType, "entityType cannot be null");
-        Preconditions.checkNotNull(listener, "listener cannot be null");
-
         RegisterListenerLocal registerListener = new RegisterListenerLocal(listener, entityType);
 
         LOG.debug("Registering listener with message: {}", registerListener);
index dd52cda..4dce320 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore.entityownership.messages;
 
+import static java.util.Objects.requireNonNull;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
 
 /**
@@ -14,13 +17,14 @@ import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener;
  *
  * @author Thomas Pantelis
  */
+@NonNullByDefault
 public class RegisterListenerLocal {
     private final DOMEntityOwnershipListener listener;
     private final String entityType;
 
-    public RegisterListenerLocal(DOMEntityOwnershipListener listener, String entityType) {
-        this.listener = listener;
-        this.entityType = entityType;
+    public RegisterListenerLocal(final DOMEntityOwnershipListener listener, final String entityType) {
+        this.listener = requireNonNull(listener, "listener cannot be null");
+        this.entityType = requireNonNull(entityType, "entityType cannot be null");
     }
 
     public DOMEntityOwnershipListener getListener() {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.