Merge "Bug 849: Fixed NPE in Translated Data Change Events."
[controller.git] / opendaylight / northbound / switchmanager / src / main / java / org / opendaylight / controller / switchmanager / northbound / NodeConnectorProperties.java
index 4e67fc405858fed4342d1b0c1921bb1f30ec67f7..bb3fc0cc036899705582315f06fbb288b40ba75d 100644 (file)
@@ -9,17 +9,23 @@
 
 package org.opendaylight.controller.switchmanager.northbound;
 
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlElementRef;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
 
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 /**
  * The class describes set of properties attached to a node connector
  */
@@ -29,8 +35,10 @@ import org.opendaylight.controller.sal.core.Property;
 public class NodeConnectorProperties {
     @XmlElement
     private NodeConnector nodeconnector;
-    @XmlElementRef
+
+    @XmlElement(name="property")
     @XmlElementWrapper
+    @JsonIgnore
     private Set<Property> properties;
 
     // JAXB required constructor
@@ -44,6 +52,19 @@ public class NodeConnectorProperties {
         this.properties = properties;
     }
 
+    @JsonProperty(value="properties")
+    public Map<String, Property> getMapProperties() {
+        Map<String, Property> map = new HashMap<String, Property>();
+        for (Property p : properties) {
+            map.put(p.getName(), p);
+        }
+        return map;
+    }
+
+    public void setMapProperties(Map<String, Property> propertiesMap) {
+        this.properties = new HashSet<Property>(propertiesMap.values());
+    }
+
     public Set<Property> getProperties() {
         return properties;
     }