ipv6service: drop nullToEmpty and reqNonNullOrElse 18/79918/4
authorStephen Kitt <skitt@redhat.com>
Fri, 25 Jan 2019 08:53:23 +0000 (09:53 +0100)
committerSam Hague <shague@redhat.com>
Mon, 28 Jan 2019 15:20:54 +0000 (15:20 +0000)
Change-Id: I7796fd461a13f76a62320586fcb194bcc314dbb6
Signed-off-by: Stephen Kitt <skitt@redhat.com>
ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/Ipv6RouterAdvt.java
ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/NeutronPortChangeListener.java
ipv6service/impl/src/main/java/org/opendaylight/netvirt/ipv6service/utils/Ipv6ServiceUtils.java

index 05871cb7b86bd0626ab4466520085435faa0a68b..6518d3eca6bcab741f281e6d780489025fc0435d 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.netvirt.ipv6service;
 
 import static java.util.Objects.requireNonNull;
 
-import static org.opendaylight.netvirt.ipv6service.utils.Ipv6ServiceUtils.nullToEmpty;
-
 import java.math.BigInteger;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
@@ -240,7 +238,7 @@ public class Ipv6RouterAdvt {
             buf.putInt((int)pdu.getMtu().longValue());
         }
 
-        for (PrefixList prefix : nullToEmpty(pdu.getPrefixList())) {
+        for (PrefixList prefix : pdu.nonnullPrefixList()) {
             buf.put((byte)prefix.getOptionType().shortValue());
             buf.put((byte)prefix.getOptionLength().shortValue());
             buf.put((byte)prefix.getPrefixLength().shortValue());
index 33d2a206568ec4bc7981e77bb4e011954bd1fd88..66a09afd1f8bd2b1c5764b0504286daa12476ffe 100644 (file)
@@ -7,10 +7,7 @@
  */
 package org.opendaylight.netvirt.ipv6service;
 
-import static org.opendaylight.netvirt.ipv6service.utils.Ipv6ServiceUtils.nullToEmpty;
-
 import com.google.common.base.Strings;
-
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
@@ -69,7 +66,7 @@ public class NeutronPortChangeListener extends AsyncClusteredDataTreeChangeListe
         }
 
         LOG.debug("Add port notification handler is invoked for port {} ", port);
-        for (FixedIps fixedip : nullToEmpty(port.getFixedIps())) {
+        for (FixedIps fixedip : port.nonnullFixedIps()) {
             if (fixedip.getIpAddress().getIpv4Address() != null) {
                 continue;
             }
@@ -137,7 +134,7 @@ public class NeutronPortChangeListener extends AsyncClusteredDataTreeChangeListe
         //Neutron Port update with proper device owner information
         if ((Strings.isNullOrEmpty(original.getDeviceOwner()) || Strings.isNullOrEmpty(original.getDeviceId()))
                 && !Strings.isNullOrEmpty(update.getDeviceOwner()) && !Strings.isNullOrEmpty(update.getDeviceId())) {
-            for (FixedIps fixedip : nullToEmpty(update.getFixedIps())) {
+            for (FixedIps fixedip : update.nonnullFixedIps()) {
                 if (fixedip.getIpAddress().getIpv4Address() != null) {
                     continue;
                 }
index e424b28637f6a91596b866ba66ac20ad0bc09f0b..504fb74d83c078802992f7d933f214ac69f1e760 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.netvirt.ipv6service.utils;
 
-import static java.util.Collections.emptyList;
-
 import com.google.common.base.Optional;
 import java.math.BigInteger;
 import java.net.InetAddress;
@@ -18,7 +16,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
-import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import javax.inject.Inject;
 import javax.inject.Singleton;
@@ -436,10 +433,4 @@ public class Ipv6ServiceUtils {
         }
         return subnet.getIpVersion().equals(Ipv6ServiceConstants.IP_VERSION_V6) ? true : false;
     }
-
-    // TODO Replace this with mdsal's DataObjectUtils.nullToEmpty when upgrading to mdsal 3
-    @Nonnull
-    public static <T> List<T> nullToEmpty(final @Nullable List<T> input) {
-        return input != null ? input : emptyList();
-    }
 }