Merge "Refactor Subnet.isSubnetOf - reduce number of 'if' statements. Added unitests."
authorMadhu Venugopal <mavenugo@gmail.com>
Mon, 23 Dec 2013 16:44:43 +0000 (16:44 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 23 Dec 2013 16:44:43 +0000 (16:44 +0000)
1  2 
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java

index 16c09fe3f6a4ddfe62623293b055b53eabde15c0,6cc40193fb18d7ef493ac91f1895b9ae578a65f5..e0842593c8cf25defbabdf078c814afb7ce2cc4d
@@@ -161,15 -161,11 +161,11 @@@ public class Subnet implements Cloneabl
          }
          InetAddress thisPrefix = getPrefixForAddress(this.networkAddress);
          InetAddress otherPrefix = getPrefixForAddress(ip);
-         if ((thisPrefix == null) || (otherPrefix == null)) {
-             return false;
-         }
-         if (thisPrefix.equals(otherPrefix)) {
-             return true;
-         }
-         else {
-             return false;
+         boolean isSubnetOf = true;
+         if (((thisPrefix == null) || (otherPrefix == null)) || (!thisPrefix.equals(otherPrefix)) ) {
+             isSubnetOf = false;
          }
+         return isSubnetOf;
      }
  
      public short getVlan() {
          if (p == null) {
              return false;
          }
 -        if (this.isFlatLayer2()) {
 -            return true;
 -        }
 -        return this.nodeConnectors.contains(p);
 +        return isFlatLayer2() || nodeConnectors.contains(p);
      }
  
      public boolean isMutualExclusive(Subnet otherSubnet) {