Take advantage of nonnullFoo() 68/82168/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 20 May 2019 06:50:49 +0000 (08:50 +0200)
committerRobert Varga <nite@hq.sk>
Sun, 16 Jun 2019 11:38:52 +0000 (11:38 +0000)
Rather then having inline checks for nulls, take advantage of
built-in nonnullFull() method.

Change-Id: I20cc90de516ab8d335ad0a7353653218e5f47ae2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java

index 2a86a6e5510a79bfc92c5fa92f0f55499b63b5aa..2193a13576b0d9958dd98bbca8939b533ac94f5e 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.openflowplugin.applications.topology.manager;
 
-import java.util.Collections;
-import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
@@ -49,9 +47,7 @@ final class TopologyManagerUtil {
             return;
         }
 
-        List<Link> linkList =
-                topologyOptional.get().getLink() != null ? topologyOptional.get().getLink() : Collections.emptyList();
-        for (Link link : linkList) {
+        for (Link link : topologyOptional.get().nonnullLink()) {
             if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) {
                 manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology));
             }
@@ -79,9 +75,7 @@ final class TopologyManagerUtil {
             return;
         }
 
-        List<Link> linkList = topologyOptional.get().getLink() != null ? topologyOptional.get()
-                .getLink() : Collections.emptyList();
-        for (Link link : linkList) {
+        for (Link link : topologyOptional.get().nonnullLink()) {
             if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) {
                 manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology));
             }