Aligning JSON marshalled output for Properties similar to the XML counterpart.
[controller.git] / opendaylight / northbound / topology / src / main / java / org / opendaylight / controller / topology / northbound / EdgeProperties.java
index b8be7c18d3e948fe8dc15bb9a1ac1286d59578f6..6614bbe640d804030c5aa8fd49fb9e26a2ccc45f 100644 (file)
@@ -9,6 +9,9 @@
 
 package org.opendaylight.controller.topology.northbound;
 
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import javax.xml.bind.annotation.XmlAccessType;
@@ -18,6 +21,8 @@ import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
 import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.Property;
 
@@ -28,6 +33,7 @@ public class EdgeProperties {
     private Edge edge;
     @XmlElementRef
     @XmlElementWrapper
+    @JsonIgnore
     private Set<Property> properties;
 
     // JAXB required constructor
@@ -41,10 +47,22 @@ public class EdgeProperties {
         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;
     }
-
     public void setProperties(Set<Property> properties) {
         this.properties = properties;
     }