Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Bug #65 - Fix inconsistencies in the NB REST APIs"
[controller.git]
/
opendaylight
/
switchmanager
/
api
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
switchmanager
/
Subnet.java
diff --git
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
index e15303581f9ad32be958dd3971cd0cf92dc8d8bd..1deda7c9d0d73ff3250dbcbcb2d08c215f624954 100644
(file)
--- 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
@@
-21,14
+21,14
@@
import org.opendaylight.controller.sal.core.NodeConnector;
* The class describes subnet information including L3 address, vlan and set of
* ports associated with the subnet.
*/
* The class describes subnet information including L3 address, vlan and set of
* ports associated with the subnet.
*/
-public class Subnet implements Serializable {
+public class Subnet implements
Cloneable,
Serializable {
private static final long serialVersionUID = 1L;
// Key fields
private InetAddress networkAddress;
private short subnetMaskLength;
// Property fields
private short vlan;
private static final long serialVersionUID = 1L;
// Key fields
private InetAddress networkAddress;
private short subnetMaskLength;
// Property fields
private short vlan;
- private Set<NodeConnector> nodeConnectors;
+ private
final
Set<NodeConnector> nodeConnectors;
public Subnet(InetAddress ip, short maskLen, short vlan) {
this.networkAddress = ip;
public Subnet(InetAddress ip, short maskLen, short vlan) {
this.networkAddress = ip;
@@
-43,18
+43,21
@@
public class Subnet implements Serializable {
nodeConnectors = conf.getSubnetNodeConnectors();
}
nodeConnectors = conf.getSubnetNodeConnectors();
}
+ public Subnet(Subnet subnet) {
+ networkAddress = subnet.networkAddress;
+ subnetMaskLength = subnet.subnetMaskLength;
+ vlan = subnet.vlan;
+ nodeConnectors = new HashSet<NodeConnector>(subnet.nodeConnectors);
+ }
+
/**
* Add NodeConnectors to a subnet
*
* @param sp Set of NodeConnectors to add to the subnet
*/
public void addNodeConnectors(Set<NodeConnector> sp) {
/**
* Add NodeConnectors to a 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);
}
}
}
}
@@
-153,16
+156,20
@@
public class Subnet implements Serializable {
}
public boolean isSubnetOf(InetAddress ip) {
}
public boolean isSubnetOf(InetAddress ip) {
- if (ip == null)
+ if (ip == null)
{
return false;
return false;
+ }
InetAddress thisPrefix = getPrefixForAddress(this.networkAddress);
InetAddress otherPrefix = getPrefixForAddress(ip);
InetAddress thisPrefix = getPrefixForAddress(this.networkAddress);
InetAddress otherPrefix = getPrefixForAddress(ip);
- if ((thisPrefix == null) || (otherPrefix == null))
+ if ((thisPrefix == null) || (otherPrefix == null))
{
return false;
return false;
- if (thisPrefix.equals(otherPrefix))
+ }
+ if (thisPrefix.equals(otherPrefix)) {
return true;
return true;
- else
+ }
+ else {
return false;
return false;
+ }
}
public short getVlan() {
}
public short getVlan() {
@@
-220,7
+227,7
@@
public class Subnet implements Serializable {
public String toString() {
return ("Subnet [networkAddress=" + networkAddress.getHostAddress()
+ "/" + subnetMaskLength
public String toString() {
return ("Subnet [networkAddress=" + networkAddress.getHostAddress()
+ "/" + subnetMaskLength
- + ((vlan == 0) ? "" : ("
vlan=" + vlan)) + "
"
+ + ((vlan == 0) ? "" : ("
, vlan=" + vlan)) + ",
"
+ ((isFlatLayer2()) ? "{[*, *]}" : nodeConnectors.toString()) + "]");
}
+ ((isFlatLayer2()) ? "{[*, *]}" : nodeConnectors.toString()) + "]");
}
@@
-246,4
+253,13
@@
public class Subnet implements Serializable {
}
return true;
}
}
return true;
}
+
+ /**
+ * Implement clonable interface
+ */
+ @Override
+ public Subnet clone() {
+ return new Subnet(this);
+ }
+
}
}