Merge "Musings towards making dummyprovider accessible"
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronMeteringLabelRule.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 NeutronMeteringLabelRule implements Serializable {
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 getMeteringLabelRuleUUID() {
46         return meteringLabelRuleUUID;
47     }
48
49     public void setMeteringLabelRuleUUID(String uuid) {
50         this.meteringLabelRuleUUID = uuid;
51     }
52
53     public String getMeteringLabelRuleDirection() {
54         return meteringLabelRuleDirection;
55     }
56
57     public void setMeteringLabelRuleDirection(String direction) {
58         this.meteringLabelRuleDirection = direction;
59     }
60
61     public Boolean getMeteringLabelRuleExcluded() {
62         return meteringLabelRuleExcluded;
63     }
64
65     public void setMeteringLabelRuleExcluded(Boolean excluded) {
66         this.meteringLabelRuleExcluded = excluded;
67     }
68
69     public String getMeteringLabelRuleRemoteIPPrefix() {
70         return meteringLabelRuleRemoteIPPrefix;
71     }
72
73     public void setMeteringLabelRuleRemoteIPPrefix(String prefix) {
74         this.meteringLabelRuleRemoteIPPrefix = prefix;
75     }
76
77     public String getMeteringLabelRuleLabelID() {
78         return meteringLabelRuleLabelID;
79     }
80
81     public void setMeteringLabelRuleLabelID(String meteringLabelID) {
82         this.meteringLabelRuleLabelID = meteringLabelID;
83     }
84
85     /*
86      *  constructor
87      */
88     public NeutronMeteringLabelRule() { }
89
90     @Override
91     public String toString() {
92         return "NeutronMeteringLabelRule [id=" + meteringLabelRuleUUID +
93             ", direction=" + meteringLabelRuleDirection +
94             ", excluded=" + meteringLabelRuleExcluded +
95             ", remote_ip_prefix=" + meteringLabelRuleRemoteIPPrefix +
96             ", metering_label_id=" + meteringLabelRuleLabelID + "]";
97     }
98
99     /**
100      * This method copies selected fields from the object and returns them
101      * as a new object, suitable for marshaling.
102      *
103      * @param fields
104      *            List of attributes to be extracted
105      * @return a NeutronMeteringLabelRule object with only the selected fields
106      * populated
107      */
108     public NeutronMeteringLabelRule extractFields(List<String> fields) {
109         NeutronMeteringLabelRule ans = new NeutronMeteringLabelRule();
110         Iterator<String> i = fields.iterator();
111         while (i.hasNext()) {
112             String s = i.next();
113             if (s.equals("id")) {
114                 ans.setMeteringLabelRuleUUID(this.getMeteringLabelRuleUUID());
115             }
116             if (s.equals("direction")) {
117                 ans.setMeteringLabelRuleDirection(this.getMeteringLabelRuleDirection());
118             }
119             if (s.equals("excluded")) {
120                 ans.setMeteringLabelRuleExcluded(this.getMeteringLabelRuleExcluded());
121             }
122             if (s.equals("remote_ip_prefix")) {
123                 ans.setMeteringLabelRuleRemoteIPPrefix(this.getMeteringLabelRuleRemoteIPPrefix());
124             }
125             if (s.equals("metering_label_id")) {
126                 ans.setMeteringLabelRuleLabelID(this.getMeteringLabelRuleLabelID());
127             }
128         }
129         return ans;
130     }
131 }