BUG #4026 neutron spi: make NeutronObject implements INeutronObject
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronMeteringLabel.java
1 /*
2  * Copyright IBM Corporation, 2015.  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.neutron.spi;
10
11 import java.io.Serializable;
12
13 import java.util.Iterator;
14 import java.util.List;
15
16 import javax.xml.bind.annotation.XmlAccessType;
17 import javax.xml.bind.annotation.XmlAccessorType;
18 import javax.xml.bind.annotation.XmlElement;
19 import javax.xml.bind.annotation.XmlRootElement;
20
21 @XmlRootElement
22 @XmlAccessorType(XmlAccessType.NONE)
23 public class NeutronMeteringLabel implements Serializable, INeutronObject {
24     private static final long serialVersionUID = 1L;
25
26     @XmlElement (name = "id")
27     String meteringLabelUUID;
28
29     @XmlElement (name = "name")
30     String meteringLabelName;
31
32     @XmlElement (name = "tenant_id")
33     String tenantID;
34
35     @XmlElement (name = "description")
36     String description;
37
38     /*
39      * getters and setters
40      */
41
42     public String getID() {
43         return meteringLabelUUID;
44     }
45
46     public void setID(String id) {
47         meteringLabelUUID = id;
48     }
49
50     // @deprecated use getID()
51     public String getMeteringLabelUUID() {
52         return meteringLabelUUID;
53     }
54
55     // @deprecated use setID()
56     public void setMeteringLabelUUID(String uuid) {
57         this.meteringLabelUUID = uuid;
58     }
59
60     public String getMeteringLabelName() {
61         return meteringLabelName;
62     }
63
64     public void setMeteringLabelName(String name) {
65         this.meteringLabelName = name;
66     }
67
68     public String getMeteringLabelTenantID() {
69         return tenantID;
70     }
71
72     public void setMeteringLabelTenantID(String tenantID) {
73         this.tenantID = tenantID;
74     }
75
76     public String getMeteringLabelDescription() {
77         return description;
78     }
79
80     public void setMeteringLabelDescription(String description) {
81         this.description = description;
82     }
83
84     /*
85      *  constructor
86      */
87     public NeutronMeteringLabel() { }
88
89     @Override
90     public String toString() {
91         return "NeutronMeteringLabel [id=" + meteringLabelUUID +
92             ", name=" + meteringLabelName +
93             ", description=" + description +
94             ", tenant_id=" + tenantID + "]";
95     }
96
97     /**
98      * This method copies selected fields from the object and returns them
99      * as a new object, suitable for marshaling.
100      *
101      * @param fields
102      *            List of attributes to be extracted
103      * @return a NeutronMeteringLabel object with only the selected fields
104      * populated
105      */
106     public NeutronMeteringLabel extractFields(List<String> fields) {
107         NeutronMeteringLabel ans = new NeutronMeteringLabel();
108         Iterator<String> i = fields.iterator();
109         while (i.hasNext()) {
110             String s = i.next();
111             if (s.equals("id")) {
112                 ans.setID(this.getID());
113             }
114             if (s.equals("name")) {
115                 ans.setMeteringLabelName(this.getMeteringLabelName());
116             }
117             if (s.equals("tenant_id")) {
118                 ans.setMeteringLabelTenantID(this.getMeteringLabelTenantID());
119             }
120             if (s.equals("description")) {
121                 ans.setMeteringLabelDescription(this.getMeteringLabelDescription());
122             }
123         }
124         return ans;
125     }
126 }