Merge "BUG #4026 neutron spi: make NeutronObject implements INeutronObject"
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronMeteringLabelRule.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
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 NeutronMeteringLabelRule implements Serializable, INeutronObject {
24     private static final long serialVersionUID = 1L;
25
26     @XmlElement (name = "id")
27     String meteringLabelRuleUUID;
28
29     @XmlElement (name = "direction")
30     String meteringLabelRuleDirection;
31
32     @XmlElement (defaultValue = "false", name = "excluded")
33     Boolean meteringLabelRuleExcluded;
34
35     @XmlElement (name = "remote_ip_prefix")
36     String meteringLabelRuleRemoteIPPrefix;
37
38     @XmlElement (name = "metering_label_id")
39     String meteringLabelRuleLabelID;
40
41     /*
42      *  getters and setters
43      */
44
45     public String getID() {
46         return meteringLabelRuleUUID;
47     }
48
49     public void setID(String id) {
50         meteringLabelRuleUUID = id;
51     }
52
53     // @deprecated use getID()
54     public String getMeteringLabelRuleUUID() {
55         return meteringLabelRuleUUID;
56     }
57
58     // @deprecated use setID()
59     public void setMeteringLabelRuleUUID(String uuid) {
60         this.meteringLabelRuleUUID = uuid;
61     }
62
63     public String getMeteringLabelRuleDirection() {
64         return meteringLabelRuleDirection;
65     }
66
67     public void setMeteringLabelRuleDirection(String direction) {
68         this.meteringLabelRuleDirection = direction;
69     }
70
71     public Boolean getMeteringLabelRuleExcluded() {
72         return meteringLabelRuleExcluded;
73     }
74
75     public void setMeteringLabelRuleExcluded(Boolean excluded) {
76         this.meteringLabelRuleExcluded = excluded;
77     }
78
79     public String getMeteringLabelRuleRemoteIPPrefix() {
80         return meteringLabelRuleRemoteIPPrefix;
81     }
82
83     public void setMeteringLabelRuleRemoteIPPrefix(String prefix) {
84         this.meteringLabelRuleRemoteIPPrefix = prefix;
85     }
86
87     public String getMeteringLabelRuleLabelID() {
88         return meteringLabelRuleLabelID;
89     }
90
91     public void setMeteringLabelRuleLabelID(String meteringLabelID) {
92         this.meteringLabelRuleLabelID = meteringLabelID;
93     }
94
95     /*
96      *  constructor
97      */
98     public NeutronMeteringLabelRule() { }
99
100     @Override
101     public String toString() {
102         return "NeutronMeteringLabelRule [id=" + meteringLabelRuleUUID +
103             ", direction=" + meteringLabelRuleDirection +
104             ", excluded=" + meteringLabelRuleExcluded +
105             ", remote_ip_prefix=" + meteringLabelRuleRemoteIPPrefix +
106             ", metering_label_id=" + meteringLabelRuleLabelID + "]";
107     }
108
109     /**
110      * This method copies selected fields from the object and returns them
111      * as a new object, suitable for marshaling.
112      *
113      * @param fields
114      *            List of attributes to be extracted
115      * @return a NeutronMeteringLabelRule object with only the selected fields
116      * populated
117      */
118     public NeutronMeteringLabelRule extractFields(List<String> fields) {
119         NeutronMeteringLabelRule ans = new NeutronMeteringLabelRule();
120         Iterator<String> i = fields.iterator();
121         while (i.hasNext()) {
122             String s = i.next();
123             if (s.equals("id")) {
124                 ans.setID(this.getID());
125             }
126             if (s.equals("direction")) {
127                 ans.setMeteringLabelRuleDirection(this.getMeteringLabelRuleDirection());
128             }
129             if (s.equals("excluded")) {
130                 ans.setMeteringLabelRuleExcluded(this.getMeteringLabelRuleExcluded());
131             }
132             if (s.equals("remote_ip_prefix")) {
133                 ans.setMeteringLabelRuleRemoteIPPrefix(this.getMeteringLabelRuleRemoteIPPrefix());
134             }
135             if (s.equals("metering_label_id")) {
136                 ans.setMeteringLabelRuleLabelID(this.getMeteringLabelRuleLabelID());
137             }
138         }
139         return ans;
140     }
141 }