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

@@@ -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) {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.