Merge "Add NeutronSubnetJAXBTest unit test"
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronMeteringLabel.java
1 /*
2  * Copyright (c) 2015 IBM Corporation 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.neutron.spi;
10
11 import java.io.Serializable;
12 import java.util.Iterator;
13 import java.util.List;
14 import javax.xml.bind.annotation.XmlAccessType;
15 import javax.xml.bind.annotation.XmlAccessorType;
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlRootElement;
18
19 @XmlRootElement
20 @XmlAccessorType(XmlAccessType.NONE)
21 public class NeutronMeteringLabel extends NeutronObject<NeutronMeteringLabel>
22         implements Serializable, INeutronObject<NeutronMeteringLabel> {
23     private static final long serialVersionUID = 1L;
24
25     @XmlElement(name = "name")
26     String meteringLabelName;
27
28     @XmlElement(defaultValue = "false", name = "shared")
29     Boolean shared;
30
31     /*
32      * getters and setters
33      */
34
35     public String getMeteringLabelName() {
36         return meteringLabelName;
37     }
38
39     public void setMeteringLabelName(String name) {
40         this.meteringLabelName = name;
41     }
42
43     public Boolean getMeteringLabelShared() {
44         return shared;
45     }
46
47     public void setMeteringLabelShared(Boolean shared) {
48         this.shared = shared;
49     }
50
51     /*
52      *  constructor
53      */
54     public NeutronMeteringLabel() {
55     }
56
57     @Override
58     public String toString() {
59         return "NeutronMeteringLabel [id=" + uuid + ", name=" + meteringLabelName + ", tenant_id=" + tenantID
60                 + ", shared=" + shared + "]";
61     }
62
63     /**
64      * This method copies selected fields from the object and returns them
65      * as a new object, suitable for marshaling.
66      *
67      * @param fields
68      *            List of attributes to be extracted
69      * @return a NeutronMeteringLabel object with only the selected fields
70      * populated
71      */
72     public NeutronMeteringLabel extractFields(List<String> fields) {
73         NeutronMeteringLabel ans = new NeutronMeteringLabel();
74         Iterator<String> i = fields.iterator();
75         while (i.hasNext()) {
76             String s = i.next();
77             if (s.equals("id")) {
78                 ans.setID(this.getID());
79             }
80             if (s.equals("name")) {
81                 ans.setMeteringLabelName(this.getMeteringLabelName());
82             }
83             if (s.equals("tenant_id")) {
84                 ans.setTenantID(this.getTenantID());
85             }
86             if (s.equals("shared")) {
87                 ans.setMeteringLabelShared(this.getMeteringLabelShared());
88             }
89         }
90         return ans;
91     }
92 }