Refactor to remove empty catch exception.
[controller.git] / opendaylight / networkconfiguration / neutron / src / main / java / org / opendaylight / controller / networkconfig / neutron / NeutronSubnet.java
index c6ea9421f9b9d928944ced8e7ceeb7de40a3de6c..8b1a8d6af4bb50c13e8b2166bac245fe7d41f0ce 100644 (file)
@@ -145,15 +145,16 @@ public class NeutronSubnet {
     }\r
 \r
     public boolean isEnableDHCP() {\r
-        if (enableDHCP == null)\r
+        if (enableDHCP == null) {\r
             return true;\r
+        }\r
         return enableDHCP;\r
     }\r
 \r
     public Boolean getEnableDHCP() { return enableDHCP; }\r
 \r
     public void setEnableDHCP(Boolean newValue) {\r
-            this.enableDHCP = newValue;\r
+            enableDHCP = newValue;\r
     }\r
 \r
     public String getTenantID() {\r
@@ -179,18 +180,24 @@ public class NeutronSubnet {
         Iterator<String> i = fields.iterator();\r
         while (i.hasNext()) {\r
             String s = i.next();\r
-            if (s.equals("id"))\r
+            if (s.equals("id")) {\r
                 ans.setSubnetUUID(this.getSubnetUUID());\r
-            if (s.equals("network_id"))\r
+            }\r
+            if (s.equals("network_id")) {\r
                 ans.setNetworkUUID(this.getNetworkUUID());\r
-            if (s.equals("name"))\r
+            }\r
+            if (s.equals("name")) {\r
                 ans.setName(this.getName());\r
-            if (s.equals("ip_version"))\r
+            }\r
+            if (s.equals("ip_version")) {\r
                 ans.setIpVersion(this.getIpVersion());\r
-            if (s.equals("cidr"))\r
+            }\r
+            if (s.equals("cidr")) {\r
                 ans.setCidr(this.getCidr());\r
-            if (s.equals("gateway_ip"))\r
+            }\r
+            if (s.equals("gateway_ip")) {\r
                 ans.setGatewayIP(this.getGatewayIP());\r
+            }\r
             if (s.equals("dns_nameservers")) {\r
                 List<String> nsList = new ArrayList<String>();\r
                 nsList.addAll(this.getDnsNameservers());\r
@@ -206,10 +213,12 @@ public class NeutronSubnet {
                 hRoutes.addAll(this.getHostRoutes());\r
                 ans.setHostRoutes(hRoutes);\r
             }\r
-            if (s.equals("enable_dhcp"))\r
+            if (s.equals("enable_dhcp")) {\r
                 ans.setEnableDHCP(this.getEnableDHCP());\r
-            if (s.equals("tenant_id"))\r
+            }\r
+            if (s.equals("tenant_id")) {\r
                 ans.setTenantID(this.getTenantID());\r
+            }\r
         }\r
         return ans;\r
     }\r
@@ -222,8 +231,9 @@ public class NeutronSubnet {
         try {\r
             SubnetUtils util = new SubnetUtils(cidr);\r
             SubnetInfo info = util.getInfo();\r
-            if (!info.getNetworkAddress().equals(info.getAddress()))\r
+            if (!info.getNetworkAddress().equals(info.getAddress())) {\r
                 return false;\r
+            }\r
         } catch (Exception e) {\r
             return false;\r
         }\r
@@ -238,17 +248,20 @@ public class NeutronSubnet {
         Iterator<NeutronSubnet_IPAllocationPool> i = allocationPools.iterator();\r
         while (i.hasNext()) {\r
             NeutronSubnet_IPAllocationPool pool = i.next();\r
-            if (pool.contains(gatewayIP))\r
+            if (pool.contains(gatewayIP)) {\r
                 return true;\r
+            }\r
         }\r
         return false;\r
     }\r
 \r
-    public void initDefaults() {\r
-        if (enableDHCP == null)\r
+    public boolean initDefaults() {\r
+        if (enableDHCP == null) {\r
             enableDHCP = true;\r
-        if (ipVersion == null)\r
+        }\r
+        if (ipVersion == null) {\r
             ipVersion = 4;\r
+        }\r
         gatewayIPAssigned = false;\r
         dnsNameservers = new ArrayList<String>();\r
         allocationPools = new ArrayList<NeutronSubnet_IPAllocationPool>();\r
@@ -256,8 +269,9 @@ public class NeutronSubnet {
         try {\r
             SubnetUtils util = new SubnetUtils(cidr);\r
             SubnetInfo info = util.getInfo();\r
-            if (gatewayIP == null)\r
+            if (gatewayIP == null) {\r
                 gatewayIP = info.getLowAddress();\r
+            }\r
             if (allocationPools.size() < 1) {\r
                 NeutronSubnet_IPAllocationPool source =\r
                     new NeutronSubnet_IPAllocationPool(info.getLowAddress(),\r
@@ -265,7 +279,9 @@ public class NeutronSubnet {
                 allocationPools = source.splitPool(gatewayIP);\r
             }\r
         } catch (Exception e) {\r
+            return false;\r
         }\r
+        return true;\r
     }\r
 \r
     public List<NeutronPort> getPortsInSubnet() {\r
@@ -297,13 +313,15 @@ public class NeutronSubnet {
      * available allocation pools or not\r
      */\r
     public boolean isIPInUse(String ipAddress) {\r
-        if (ipAddress.equals(gatewayIP) && !gatewayIPAssigned )\r
+        if (ipAddress.equals(gatewayIP) && !gatewayIPAssigned ) {\r
             return false;\r
+        }\r
         Iterator<NeutronSubnet_IPAllocationPool> i = allocationPools.iterator();\r
         while (i.hasNext()) {\r
             NeutronSubnet_IPAllocationPool pool = i.next();\r
-            if (pool.contains(ipAddress))\r
+            if (pool.contains(ipAddress)) {\r
                 return false;\r
+            }\r
         }\r
         return true;\r
     }\r
@@ -322,8 +340,9 @@ public class NeutronSubnet {
             }\r
             else\r
                 if (NeutronSubnet_IPAllocationPool.convert(pool.getPoolStart()) <\r
-                        NeutronSubnet_IPAllocationPool.convert(ans))\r
+                        NeutronSubnet_IPAllocationPool.convert(ans)) {\r
                     ans = pool.getPoolStart();\r
+                }\r
         }\r
         return ans;\r
     }\r
@@ -349,8 +368,9 @@ public class NeutronSubnet {
                 if (pool.contains(ipAddress)) {\r
                     List<NeutronSubnet_IPAllocationPool> pools = pool.splitPool(ipAddress);\r
                     newList.addAll(pools);\r
-                } else\r
+                } else {\r
                     newList.add(pool);\r
+                }\r
             }\r
         }\r
         allocationPools = newList;\r
@@ -372,20 +392,25 @@ public class NeutronSubnet {
             NeutronSubnet_IPAllocationPool pool = i.next();\r
             long lIP = NeutronSubnet_IPAllocationPool.convert(pool.getPoolStart());\r
             long hIP = NeutronSubnet_IPAllocationPool.convert(pool.getPoolEnd());\r
-            if (sIP+1 == lIP)\r
+            if (sIP+1 == lIP) {\r
                 hPool = pool;\r
-            if (sIP-1 == hIP)\r
+            }\r
+            if (sIP-1 == hIP) {\r
                 lPool = pool;\r
+            }\r
         }\r
         //if (lPool == NULL and hPool == NULL) create new pool where low = ip = high\r
-        if (lPool == null && hPool == null)\r
+        if (lPool == null && hPool == null) {\r
             allocationPools.add(new NeutronSubnet_IPAllocationPool(ipAddress,ipAddress));\r
+        }\r
         //if (lPool == NULL and hPool != NULL) change low address of hPool to ipAddr\r
-        if (lPool == null && hPool != null)\r
+        if (lPool == null && hPool != null) {\r
             hPool.setPoolStart(ipAddress);\r
+        }\r
         //if (lPool != NULL and hPool == NULL) change high address of lPool to ipAddr\r
-        if (lPool != null && hPool == null)\r
+        if (lPool != null && hPool == null) {\r
             lPool.setPoolEnd(ipAddress);\r
+        }\r
         //if (lPool != NULL and hPool != NULL) remove lPool and hPool and create new pool\r
         //        where low address = lPool.low address and high address = hPool.high Address\r
         if (lPool != null && hPool != null) {\r