From: Madhu Venugopal Date: Mon, 23 Dec 2013 16:44:43 +0000 (+0000) Subject: Merge "Refactor Subnet.isSubnetOf - reduce number of 'if' statements. Added unitests." X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~152 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=c541f7868e6e2d654b8080b5426bb12a39bddf11;hp=-c Merge "Refactor Subnet.isSubnetOf - reduce number of 'if' statements. Added unitests." --- c541f7868e6e2d654b8080b5426bb12a39bddf11 diff --combined opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java index 16c09fe3f6,6cc40193fb..e0842593c8 --- a/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java +++ b/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() { @@@ -244,7 -240,10 +240,7 @@@ 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) {