}
public Subnet(SubnetConfig conf) {
- networkAddress = conf.getIPnum();
+ networkAddress = conf.getIPAddress();
subnetMaskLength = conf.getIPMaskLen();
- nodeConnectors = conf.getSubnetNodeConnectors();
+ nodeConnectors = conf.getNodeConnectors();
}
public Subnet(Subnet subnet) {
* @param sp Set of NodeConnectors to add to the subnet
*/
public void addNodeConnectors(Set<NodeConnector> sp) {
- if (sp == null) {
- return;
- }
-
- for (NodeConnector p : sp) {
- this.nodeConnectors.add(p);
+ if (sp != null) {
+ this.nodeConnectors.addAll(sp);
}
}
}
public boolean isSubnetOf(InetAddress ip) {
- if (ip == null)
+ if (ip == null) {
return false;
+ }
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() {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Subnet other = (Subnet) obj;
if (networkAddress == null) {
- if (other.networkAddress != null)
+ if (other.networkAddress != null) {
return false;
- } else if (!networkAddress.equals(other.networkAddress))
+ }
+ } else if (!networkAddress.equals(other.networkAddress)) {
return false;
+ }
if (nodeConnectors == null) {
- if (other.nodeConnectors != null)
+ if (other.nodeConnectors != null) {
return false;
- } else if (!nodeConnectors.equals(other.nodeConnectors))
+ }
+ } else if (!nodeConnectors.equals(other.nodeConnectors)) {
return false;
- if (subnetMaskLength != other.subnetMaskLength)
+ }
+ if (subnetMaskLength != other.subnetMaskLength) {
return false;
- if (vlan != other.vlan)
+ }
+ if (vlan != other.vlan) {
return false;
+ }
return true;
}
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) {
- if (this.networkAddress.getClass() != otherSubnet.networkAddress
- .getClass())
- return true;
- if (this.isSubnetOf(otherSubnet.getNetworkAddress())) {
- return false;
- }
- if (otherSubnet.isSubnetOf(this.getNetworkAddress())) {
- return false;
- }
- return true;
+ return !(isSubnetOf(otherSubnet.getNetworkAddress()) || otherSubnet.isSubnetOf(getNetworkAddress()));
}
/**