6614bbe640d804030c5aa8fd49fb9e26a2ccc45f
[controller.git] / opendaylight / northbound / topology / src / main / java / org / opendaylight / controller / topology / northbound / EdgeProperties.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.topology.northbound;
11
12 import java.util.HashMap;
13 import java.util.HashSet;
14 import java.util.Map;
15 import java.util.Set;
16
17 import javax.xml.bind.annotation.XmlAccessType;
18 import javax.xml.bind.annotation.XmlAccessorType;
19 import javax.xml.bind.annotation.XmlElement;
20 import javax.xml.bind.annotation.XmlElementRef;
21 import javax.xml.bind.annotation.XmlElementWrapper;
22 import javax.xml.bind.annotation.XmlRootElement;
23
24 import org.codehaus.jackson.annotate.JsonIgnore;
25 import org.codehaus.jackson.annotate.JsonProperty;
26 import org.opendaylight.controller.sal.core.Edge;
27 import org.opendaylight.controller.sal.core.Property;
28
29 @XmlRootElement
30 @XmlAccessorType(XmlAccessType.NONE)
31 public class EdgeProperties {
32     @XmlElement
33     private Edge edge;
34     @XmlElementRef
35     @XmlElementWrapper
36     @JsonIgnore
37     private Set<Property> properties;
38
39     // JAXB required constructor
40     private EdgeProperties() {
41         this.edge = null;
42         this.properties = null;
43     }
44
45     public EdgeProperties(Edge e, Set<Property> properties) {
46         this.edge = e;
47         this.properties = properties;
48     }
49
50     @JsonProperty(value="properties")
51     public Map<String, Property> getMapProperties() {
52         Map<String, Property> map = new HashMap<String, Property>();
53         for (Property p : properties) {
54             map.put(p.getName(), p);
55         }
56         return map;
57     }
58
59     public void setMapProperties(Map<String, Property> propertiesMap) {
60         this.properties = new HashSet<Property>(propertiesMap.values());
61     }
62
63     public Set<Property> getProperties() {
64         return properties;
65     }
66     public void setProperties(Set<Property> properties) {
67         this.properties = properties;
68     }
69
70     public Edge getEdge() {
71         return edge;
72     }
73
74     public void setEdge(Edge edge) {
75         this.edge = edge;
76     }
77 }