Clean up collapsable if statements 69/24069/1
authorRyan Moats <rmoats@us.ibm.com>
Mon, 13 Jul 2015 19:35:29 +0000 (14:35 -0500)
committerRyan Moats <rmoats@us.ibm.com>
Mon, 13 Jul 2015 19:35:29 +0000 (14:35 -0500)
Change-Id: I019fa5d09467fe2323ae86c8260e25dacb475758
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSubnet.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronPortInterface.java

index 9461d054897f2c1648e395eb3c9647da2051b3b0..f118c7c60bd5c9e8731a4b7572f79e0746047f04 100644 (file)
@@ -314,15 +314,11 @@ public class NeutronSubnet implements Serializable, INeutronObject {
         Iterator<NeutronSubnetIPAllocationPool> i = allocationPools.iterator();
         while (i.hasNext()) {
             NeutronSubnetIPAllocationPool pool = i.next();
-            if (ipVersion == IPV4_VERSION) {
-                if (pool.contains(gatewayIP)) {
-                    return true;
-                }
+            if (ipVersion == IPV4_VERSION && pool.contains(gatewayIP)) {
+                return true;
             }
-            if (ipVersion == IPV6_VERSION) {
-                if (pool.containsV6(gatewayIP)) {
-                    return true;
-                }
+            if (ipVersion == IPV6_VERSION && pool.containsV6(gatewayIP)) {
+                return true;
             }
         }
         return false;
@@ -503,16 +499,14 @@ public class NeutronSubnet implements Serializable, INeutronObject {
                 ans = pool.getPoolStart();
             }
             else {
-                if (ipVersion == IPV4_VERSION) {
-                    if (NeutronSubnetIPAllocationPool.convert(pool.getPoolStart()) <
+                if (ipVersion == IPV4_VERSION &&
+                    NeutronSubnetIPAllocationPool.convert(pool.getPoolStart()) <
                             NeutronSubnetIPAllocationPool.convert(ans)) {
-                        ans = pool.getPoolStart();
-                    }
+                    ans = pool.getPoolStart();
                 }
-                if (ipVersion == IPV6_VERSION) {
-                    if (NeutronSubnetIPAllocationPool.convertV6(pool.getPoolStart()).compareTo(NeutronSubnetIPAllocationPool.convertV6(ans)) < 0) {
-                        ans = pool.getPoolStart();
-                    }
+                if (ipVersion == IPV6_VERSION &&
+                    NeutronSubnetIPAllocationPool.convertV6(pool.getPoolStart()).compareTo(NeutronSubnetIPAllocationPool.convertV6(ans)) < 0) {
+                    ans = pool.getPoolStart();
                 }
            }
         }
index c6e91b918274a8962d6b745ca9586dd8867af2b9..23e9b0448c0e58f210013f2e23c0411ba07af22e 100644 (file)
@@ -325,10 +325,9 @@ public class NeutronPortsNorthbound {
                     }
                     for (Neutron_IPs test_fixedIP : test.getFixedIPs()) {
                         for (Neutron_IPs check_fixedIP : check.getFixedIPs()) {
-                            if (test_fixedIP.getSubnetUUID().equals(check_fixedIP.getSubnetUUID())) {
-                                if (test_fixedIP.getIpAddress().equals(check_fixedIP.getIpAddress())) {
-                                    throw new ResourceConflictException("IP address already allocated");
-                                }
+                            if (test_fixedIP.getSubnetUUID().equals(check_fixedIP.getSubnetUUID()) &&
+                                (test_fixedIP.getIpAddress().equals(check_fixedIP.getIpAddress()))) {
+                                throw new ResourceConflictException("IP address already allocated");
                             }
                         }
                     }
index dc47ab33fefe4c43fc3725240f8774a9c5902169..655af6f71a3a4d26025ca43f71d7996a1e121f26 100644 (file)
@@ -198,10 +198,8 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
         while (portIterator.hasNext()) {
             NeutronPort port = portIterator.next();
             List<Neutron_IPs> fixedIPs = port.getFixedIPs();
-            if (fixedIPs.size() == 1) {
-                if (subnet.getGatewayIP().equals(fixedIPs.get(0).getIpAddress())) {
-                    return port;
-                }
+            if (fixedIPs.size() == 1 && subnet.getGatewayIP().equals(fixedIPs.get(0).getIpAddress())) {
+                return port;
             }
         }
         return null;