Use Set for Subnet's NodeConnectors
[controller.git] / opendaylight / switchmanager / api / src / main / java / org / opendaylight / controller / switchmanager / SubnetConfig.java
index 895f117321a6c61645742e425bcf0ad2d0af6cbd..4ed9934b27a3f6d3105c2854c86c48f131fe40c6 100644 (file)
@@ -34,7 +34,7 @@ import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)
-public class SubnetConfig implements Serializable {
+public class SubnetConfig implements Cloneable, Serializable {
     //static fields are by default excluded by Gson parser
     private static final long serialVersionUID = 1L;
     private static final String prettyFields[] = { GUIField.NAME.toString(),
@@ -48,23 +48,29 @@ public class SubnetConfig implements Serializable {
     private String subnet; // A.B.C.D/MM  Where A.B.C.D is the Default
                            // Gateway IP (L3) or ARP Querier IP (L2
     @XmlElement
-    private List<String> nodePorts; // datapath ID/port list:
+    private Set<String> nodePorts; // datapath ID/port list:
                                     // xx:xx:xx:xx:xx:xx:xx:xx/a,b,c-m,r-t,y
 
     public SubnetConfig() {
     }
 
-    public SubnetConfig(String desc, String sub, List<String> sp) {
+    public SubnetConfig(String desc, String sub, Set<String> sp) {
         name = desc;
         subnet = sub;
         nodePorts = sp;
     }
 
+    public SubnetConfig(SubnetConfig subnetConfig) {
+        name = subnetConfig.name;
+        subnet = subnetConfig.subnet;
+        nodePorts = new HashSet<String>(subnetConfig.nodePorts);
+    }
+
     public String getName() {
         return name;
     }
 
-    public List<String> getNodePorts() {
+    public Set<String> getNodePorts() {
         return nodePorts;
     }
 
@@ -233,7 +239,16 @@ public class SubnetConfig implements Serializable {
 
     @Override
     public String toString() {
-        return ("Subnet Config [Description=" + name + " Subnet=" + subnet
-                + " NodeConnectors=" + nodePorts + "]");
+        return ("SubnetConfig [Description=" + name + ", Subnet=" + subnet
+                + ", NodeConnectors=" + nodePorts + "]");
+    }
+
+    /**
+     * Implement clonable interface
+     */
+    @Override
+    public SubnetConfig clone() {
+        return new SubnetConfig(this);
     }
+
 }