Fixed bugs while getting demo.py to work.
[affinity.git] / affinity / northbound / src / main / java / org / opendaylight / affinity / affinity / northbound / AffinityLinkNorthbound.java
1 /*
2  * Copyright (c) 2013 Plexxi, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.affinity.affinity.northbound;
10
11 import java.util.ArrayList;
12 import java.util.List;
13 import java.util.HashMap;
14
15 import javax.xml.bind.annotation.XmlAccessType;
16 import javax.xml.bind.annotation.XmlAccessorType;
17 import javax.xml.bind.annotation.XmlElement;
18 import javax.xml.bind.annotation.XmlAttribute;
19 import javax.xml.bind.annotation.XmlRootElement;
20
21 import org.opendaylight.affinity.affinity.AffinityLink;
22 import org.opendaylight.affinity.affinity.AffinityAttribute;
23 import org.opendaylight.affinity.affinity.AffinityAttributeType;
24
25 // API object to be returned in GET calls.
26 @XmlRootElement
27 @XmlAccessorType(XmlAccessType.NONE)
28 public class AffinityLinkNorthbound {
29         @XmlAttribute 
30         private String name;
31         @XmlElement
32         private List<AffinityAttribute> attrlist;
33     
34         public AffinityLinkNorthbound() {
35         }
36         public AffinityLinkNorthbound(AffinityLink al) {
37             HashMap<AffinityAttributeType, AffinityAttribute> attrs = al.getAttributeList();
38
39             attrlist = new ArrayList<AffinityAttribute>();
40
41             if (attrs != null) {
42                 for (AffinityAttribute a: attrs.values()) {
43                     this.attrlist.add(a);
44                 }
45             }
46         }
47 }