b5a486c31cee6766fe9a0e1a8afb459ae8c0e391
[openflowjava.git] / third-party / openflowj_netty / src / main / java / org / openflow / protocol / statistics / OFAggregateStatisticsReply.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_aggregate_stats_reply structure
25  * @author David Erickson (daviderickson@cs.stanford.edu)
26  */
27 public class OFAggregateStatisticsReply implements OFStatistics {
28     protected long packetCount;
29     protected long byteCount;
30     protected int flowCount;
31
32     /**
33      * @return the packetCount
34      */
35     public long getPacketCount() {
36         return packetCount;
37     }
38
39     /**
40      * @param packetCount the packetCount to set
41      */
42     public void setPacketCount(long packetCount) {
43         this.packetCount = packetCount;
44     }
45
46     /**
47      * @return the byteCount
48      */
49     public long getByteCount() {
50         return byteCount;
51     }
52
53     /**
54      * @param byteCount the byteCount to set
55      */
56     public void setByteCount(long byteCount) {
57         this.byteCount = byteCount;
58     }
59
60     /**
61      * @return the flowCount
62      */
63     public int getFlowCount() {
64         return flowCount;
65     }
66
67     /**
68      * @param flowCount the flowCount to set
69      */
70     public void setFlowCount(int flowCount) {
71         this.flowCount = flowCount;
72     }
73
74     @Override
75     public int getLength() {
76         return 24;
77     }
78
79     @Override
80     public void readFrom(ChannelBuffer data) {
81         this.packetCount = data.readLong();
82         this.byteCount = data.readLong();
83         this.flowCount = data.readInt();
84         data.readInt(); // pad
85     }
86
87     @Override
88     public void writeTo(ChannelBuffer data) {
89         data.writeLong(this.packetCount);
90         data.writeLong(this.byteCount);
91         data.writeInt(this.flowCount);
92         data.writeInt(0); // pad
93     }
94
95     @Override
96     public int hashCode() {
97         final int prime = 397;
98         int result = 1;
99         result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
100         result = prime * result + flowCount;
101         result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
102         return result;
103     }
104
105     @Override
106     public boolean equals(Object obj) {
107         if (this == obj) {
108             return true;
109         }
110         if (obj == null) {
111             return false;
112         }
113         if (!(obj instanceof OFAggregateStatisticsReply)) {
114             return false;
115         }
116         OFAggregateStatisticsReply other = (OFAggregateStatisticsReply) obj;
117         if (byteCount != other.byteCount) {
118             return false;
119         }
120         if (flowCount != other.flowCount) {
121             return false;
122         }
123         if (packetCount != other.packetCount) {
124             return false;
125         }
126         return true;
127     }
128 }