Fix checkstyle warnings in netconf-cli
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / queue / OFQueuePropertyMinRate.java
1 package org.openflow.protocol.queue;
2
3 import java.nio.ByteBuffer;
4
5 import org.openflow.util.U16;
6
7 /**
8  * Corresponds to the struct struct ofp_queue_prop_min_rate OpenFlow structure
9  *
10  * @author David Erickson (daviderickson@cs.stanford.edu)
11  */
12 public class OFQueuePropertyMinRate extends OFQueueProperty {
13     public static int MINIMUM_LENGTH = 16;
14
15     protected short rate;
16
17     /**
18      * 
19      */
20     public OFQueuePropertyMinRate() {
21         super();
22         this.type = OFQueuePropertyType.MIN_RATE;
23         this.length = U16.t(MINIMUM_LENGTH);
24     }
25
26     /**
27      * @return the rate
28      */
29     public short getRate() {
30         return rate;
31     }
32
33     /**
34      * @param rate the rate to set
35      */
36     public OFQueuePropertyMinRate setRate(short rate) {
37         this.rate = rate;
38         return this;
39     }
40
41     @Override
42     public void readFrom(ByteBuffer data) {
43         super.readFrom(data);
44         this.rate = data.getShort();
45         data.getInt(); // pad
46         data.getShort(); // pad
47     }
48
49     @Override
50     public void writeTo(ByteBuffer data) {
51         super.writeTo(data);
52         data.putShort(this.rate);
53         data.putInt(0); // pad
54         data.putShort((short) 0); // pad
55     }
56
57     @Override
58     public int hashCode() {
59         final int prime = 3259;
60         int result = super.hashCode();
61         result = prime * result + rate;
62         return result;
63     }
64
65     @Override
66     public boolean equals(Object obj) {
67         if (this == obj)
68             return true;
69         if (!super.equals(obj))
70             return false;
71         if (!(obj instanceof OFQueuePropertyMinRate))
72             return false;
73         OFQueuePropertyMinRate other = (OFQueuePropertyMinRate) obj;
74         if (rate != other.rate)
75             return false;
76         return true;
77     }
78
79     /* (non-Javadoc)
80      * @see java.lang.Object#toString()
81      */
82     @Override
83     public String toString() {
84         return "OFQueuePropertyMinRate [type=" + type + ", rate=" + U16.f(rate) + "]";
85     }
86
87 }