QoS: Add support for direction
[neutron.git] / neutron-spi / src / main / java / org / opendaylight / neutron / spi / NeutronQosBandwidthLimitRule.java
1 /*
2  * Copyright (c) 2016, 2017 Intel Corporation.  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.math.BigInteger;
12 import javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlElement;
15 import javax.xml.bind.annotation.XmlRootElement;
16
17 @XmlRootElement
18 @XmlAccessorType(XmlAccessType.NONE)
19 public final class NeutronQosBandwidthLimitRule extends NeutronObject<NeutronQosBandwidthLimitRule> {
20     private static final long serialVersionUID = 1L;
21
22     @XmlElement(name = "max_kbps")
23     BigInteger maxKbps;
24
25     @XmlElement(name = "max_burst_kbps")
26     BigInteger maxBurstKbps;
27
28     @XmlElement(defaultValue = "egress", name = "direction")
29     String direction;
30
31     public BigInteger getMaxKbps() {
32         return maxKbps;
33     }
34
35     public void setMaxKbps(BigInteger maxKbps) {
36         this.maxKbps = maxKbps;
37     }
38
39     public BigInteger getMaxBurstKbps() {
40         return maxBurstKbps;
41     }
42
43     public void setMaxBurstKbps(BigInteger maxBurstKbps) {
44         this.maxBurstKbps = maxBurstKbps;
45     }
46
47     public String getDirection() {
48         return direction;
49     }
50
51     public void setDirection(String direction) {
52         this.direction = direction;
53     }
54
55     @Override
56     public boolean extractField(String field, NeutronQosBandwidthLimitRule ans) {
57         switch (field) {
58             case "max_kbps":
59                 ans.setMaxKbps(this.getMaxKbps());
60                 break;
61             case "max_burst_kbps":
62                 ans.setMaxBurstKbps(this.getMaxBurstKbps());
63                 break;
64             case "direction":
65                 ans.setDirection(this.getDirection());
66                 break;
67             default:
68                 return super.extractField(field, ans);
69         }
70         return true;
71     }
72
73     @Override
74     public String toString() {
75         return "qosBandwidthLimitRules{" + "qosBandwidthLimitRuleUUID='" + uuid + '\''
76             + ", qosBandwidthLimitRuleTenantID='" + tenantID + '\'' + ", qosBandwidthLimitRuleMaxValue='" + maxKbps
77             + '\'' + ", qosBandwidthLimitRuleMaxBurst='" + maxBurstKbps
78             + '\'' + ", qosBandwidthLimitRuleDirection='" + direction
79             + '\''
80             + '}';
81     }
82 }