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