Fix a couple of warnings in l3vpn 40/72640/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jun 2018 08:50:01 +0000 (10:50 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jun 2018 09:42:19 +0000 (11:42 +0200)
- static method
- unnecessary if/else

Change-Id: I1efa627d7cd4ffcef239caac0244581921fae376
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/ipv4/VpnIpv4NlriParser.java
bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/ipv6/VpnIpv6NlriParser.java

index 6abb15caec3b0f85b980f8929ddbf5d4f77dad0d..83bf76e85440d40afae178b9d3df47f156f862c7 100644 (file)
@@ -20,31 +20,28 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.
 
 public final class VpnIpv4NlriParser extends AbstractVpnNlriParser {
 
-    private <T extends L3vpnIpv4Destination> List<VpnDestination> getVpnDestination(DestinationType dst,
-            Class<T> dstTypeCaseClazz) {
-        if (dstTypeCaseClazz.isInstance(dst)) {
-            return dstTypeCaseClazz.cast(dst).getVpnIpv4Destination().getVpnDestination();
-        } else {
-            return null;
-        }
+    private static <T extends L3vpnIpv4Destination> List<VpnDestination> getVpnDestination(final DestinationType dst,
+            final Class<T> dstTypeCaseClazz) {
+        return dstTypeCaseClazz.isInstance(dst) ? dstTypeCaseClazz.cast(dst).getVpnIpv4Destination().getVpnDestination()
+                : null;
     }
 
     @Override
-    protected List<VpnDestination> getWithdrawnVpnDestination(DestinationType dstType) {
+    protected List<VpnDestination> getWithdrawnVpnDestination(final DestinationType dstType) {
         return getVpnDestination(dstType, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4
                 .rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
                 .DestinationVpnIpv4Case.class);
     }
 
     @Override
-    protected List<VpnDestination> getAdvertizedVpnDestination(DestinationType dstType) {
+    protected List<VpnDestination> getAdvertizedVpnDestination(final DestinationType dstType) {
         return getVpnDestination(dstType, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4
                 .rev180329.update.attributes.mp.reach.nlri.advertized.routes.destination.type
                 .DestinationVpnIpv4Case.class);
     }
 
     @Override
-    protected WithdrawnRoutes getWithdrawnRoutesByDestination(List<VpnDestination> dst) {
+    protected WithdrawnRoutes getWithdrawnRoutesByDestination(final List<VpnDestination> dst) {
         return new WithdrawnRoutesBuilder().setDestinationType(
             new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
                     .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
@@ -53,7 +50,7 @@ public final class VpnIpv4NlriParser extends AbstractVpnNlriParser {
     }
 
     @Override
-    protected AdvertizedRoutes getAdvertizedRoutesByDestination(List<VpnDestination> dst) {
+    protected AdvertizedRoutes getAdvertizedRoutesByDestination(final List<VpnDestination> dst) {
         return new AdvertizedRoutesBuilder().setDestinationType(
             new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
                     .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder()
index 195330c3d723a6761c8c6cef42c52b25114b1be2..4c430066eeb62a6ecbfb5b37c63c9ae91094b68e 100644 (file)
@@ -20,24 +20,21 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.
 
 public class VpnIpv6NlriParser extends AbstractVpnNlriParser {
 
-    private <T extends L3vpnIpv6Destination> List<VpnDestination> getVpnDestination(DestinationType dst,
-            Class<T> dstTypeCaseClazz) {
-        if (dstTypeCaseClazz.isInstance(dst)) {
-            return dstTypeCaseClazz.cast(dst).getVpnIpv6Destination().getVpnDestination();
-        } else {
-            return null;
-        }
+    private static <T extends L3vpnIpv6Destination> List<VpnDestination> getVpnDestination(final DestinationType dst,
+            final Class<T> dstTypeCaseClazz) {
+        return dstTypeCaseClazz.isInstance(dst) ? dstTypeCaseClazz.cast(dst).getVpnIpv6Destination().getVpnDestination()
+                : null;
     }
 
     @Override
-    protected List<VpnDestination> getWithdrawnVpnDestination(DestinationType dstType) {
+    protected List<VpnDestination> getWithdrawnVpnDestination(final DestinationType dstType) {
         return getVpnDestination(dstType,
             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update.attributes
                     .mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6Case.class);
     }
 
     @Override
-    protected List<VpnDestination> getAdvertizedVpnDestination(DestinationType dstType) {
+    protected List<VpnDestination> getAdvertizedVpnDestination(final DestinationType dstType) {
         return getVpnDestination(
             dstType,
             org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update.attributes
@@ -45,7 +42,7 @@ public class VpnIpv6NlriParser extends AbstractVpnNlriParser {
     }
 
     @Override
-    protected WithdrawnRoutes getWithdrawnRoutesByDestination(List<VpnDestination> dst) {
+    protected WithdrawnRoutes getWithdrawnRoutesByDestination(final List<VpnDestination> dst) {
         return new WithdrawnRoutesBuilder().setDestinationType(
             new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
                     .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
@@ -54,7 +51,7 @@ public class VpnIpv6NlriParser extends AbstractVpnNlriParser {
     }
 
     @Override
-    protected AdvertizedRoutes getAdvertizedRoutesByDestination(List<VpnDestination> dst) {
+    protected AdvertizedRoutes getAdvertizedRoutesByDestination(final List<VpnDestination> dst) {
         return new AdvertizedRoutesBuilder().setDestinationType(
             new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
                     .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder()