7d0238a3fffcd2fbf9e90450bdb3ef946924b8c6
[openflowjava.git] / third-party / openflowj_netty / src / main / java / org / openflow / protocol / statistics / OFQueueStatisticsReply.java
1 /**
2 *    Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
3 *    University
4
5 *    Licensed under the Apache License, Version 2.0 (the "License"); you may
6 *    not use this file except in compliance with the License. You may obtain
7 *    a copy of the License at
8 *
9 *         http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *    Unless required by applicable law or agreed to in writing, software
12 *    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 *    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 *    License for the specific language governing permissions and limitations
15 *    under the License.
16 **/
17
18 package org.openflow.protocol.statistics;
19
20
21 import org.jboss.netty.buffer.ChannelBuffer;
22
23 /**
24  * Represents an ofp_queue_stats structure
25  * @author David Erickson (daviderickson@cs.stanford.edu)
26  */
27 public class OFQueueStatisticsReply implements OFStatistics {
28     protected short portNumber;
29     protected int queueId;
30     protected long transmitBytes;
31     protected long transmitPackets;
32     protected long transmitErrors;
33
34     /**
35      * @return the portNumber
36      */
37     public short getPortNumber() {
38         return portNumber;
39     }
40
41     /**
42      * @param portNumber the portNumber to set
43      */
44     public void setPortNumber(short portNumber) {
45         this.portNumber = portNumber;
46     }
47
48     /**
49      * @return the queueId
50      */
51     public int getQueueId() {
52         return queueId;
53     }
54
55     /**
56      * @param queueId the queueId to set
57      */
58     public void setQueueId(int queueId) {
59         this.queueId = queueId;
60     }
61
62     /**
63      * @return the transmitBytes
64      */
65     public long getTransmitBytes() {
66         return transmitBytes;
67     }
68
69     /**
70      * @param transmitBytes the transmitBytes to set
71      */
72     public void setTransmitBytes(long transmitBytes) {
73         this.transmitBytes = transmitBytes;
74     }
75
76     /**
77      * @return the transmitPackets
78      */
79     public long getTransmitPackets() {
80         return transmitPackets;
81     }
82
83     /**
84      * @param transmitPackets the transmitPackets to set
85      */
86     public void setTransmitPackets(long transmitPackets) {
87         this.transmitPackets = transmitPackets;
88     }
89
90     /**
91      * @return the transmitErrors
92      */
93     public long getTransmitErrors() {
94         return transmitErrors;
95     }
96
97     /**
98      * @param transmitErrors the transmitErrors to set
99      */
100     public void setTransmitErrors(long transmitErrors) {
101         this.transmitErrors = transmitErrors;
102     }
103
104     @Override
105     public int getLength() {
106         return 32;
107     }
108
109     @Override
110     public void readFrom(ChannelBuffer data) {
111         this.portNumber = data.readShort();
112         data.readShort(); // pad
113         this.queueId = data.readInt();
114         this.transmitBytes = data.readLong();
115         this.transmitPackets = data.readLong();
116         this.transmitErrors = data.readLong();
117     }
118
119     @Override
120     public void writeTo(ChannelBuffer data) {
121         data.writeShort(this.portNumber);
122         data.writeShort((short) 0); // pad
123         data.writeInt(this.queueId);
124         data.writeLong(this.transmitBytes);
125         data.writeLong(this.transmitPackets);
126         data.writeLong(this.transmitErrors);
127     }
128
129     @Override
130     public int hashCode() {
131         final int prime = 439;
132         int result = 1;
133         result = prime * result + portNumber;
134         result = prime * result + queueId;
135         result = prime * result
136                 + (int) (transmitBytes ^ (transmitBytes >>> 32));
137         result = prime * result
138                 + (int) (transmitErrors ^ (transmitErrors >>> 32));
139         result = prime * result
140                 + (int) (transmitPackets ^ (transmitPackets >>> 32));
141         return result;
142     }
143
144     @Override
145     public boolean equals(Object obj) {
146         if (this == obj) {
147             return true;
148         }
149         if (obj == null) {
150             return false;
151         }
152         if (!(obj instanceof OFQueueStatisticsReply)) {
153             return false;
154         }
155         OFQueueStatisticsReply other = (OFQueueStatisticsReply) obj;
156         if (portNumber != other.portNumber) {
157             return false;
158         }
159         if (queueId != other.queueId) {
160             return false;
161         }
162         if (transmitBytes != other.transmitBytes) {
163             return false;
164         }
165         if (transmitErrors != other.transmitErrors) {
166             return false;
167         }
168         if (transmitPackets != other.transmitPackets) {
169             return false;
170         }
171         return true;
172     }
173 }