Use Objects.requireNonNullElse() 63/93863/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 17 Nov 2020 14:42:04 +0000 (15:42 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 17 Nov 2020 15:43:25 +0000 (16:43 +0100)
Modernizer is pointing this one out, drop the MoreObjects
dependency.

Change-Id: Ibfe3f79dae3b53bc30d130ae68bfab83214ee128
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 98137e91bb5896d111293f8109bed42b3454b943)

opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java

index d6b8c02a4d53614d368c55ba5a5e6cad57e1afe4..5029e0cc861a2401ed7e985fe4a62d1031e9e158 100644 (file)
@@ -12,11 +12,11 @@ import static com.google.common.base.Preconditions.checkState;
 import static com.google.common.base.Verify.verify;
 import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
+import static java.util.Objects.requireNonNullElse;
 
 import akka.actor.ActorRef;
 import akka.util.Timeout;
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.MoreObjects;
 import com.google.common.base.Stopwatch;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
@@ -1285,7 +1285,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
             return false;
         }
 
-        DataTreeTip newTip = MoreObjects.firstNonNull(first.cohort.getCandidate(), dataTree);
+        DataTreeTip newTip = requireNonNullElse(first.cohort.getCandidate(), dataTree);
         while (it.hasNext()) {
             final CommitEntry e = it.next();
             if (cohort.equals(e.cohort)) {
@@ -1298,7 +1298,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
 
                 return true;
             } else {
-                newTip = MoreObjects.firstNonNull(e.cohort.getCandidate(), newTip);
+                newTip = requireNonNullElse(e.cohort.getCandidate(), newTip);
             }
         }