77c45aba7fd51ddc66808f40b13841cd3cf30651
[openflowjava.git] / third-party / openflow-codec / src / main / java / org / openflow / codec / protocol / statistics / OFPAggregateStatisticsReply.java
1 package org.openflow.codec.protocol.statistics;
2
3 import org.openflow.codec.io.IDataBuffer;
4
5 /**
6  * Represents an ofp_aggregate_stats_reply structure
7  *
8  * @author David Erickson (daviderickson@cs.stanford.edu)
9  */
10 public class OFPAggregateStatisticsReply implements OFPStatistics {
11     protected long packetCount;
12     protected long byteCount;
13     protected int flowCount;
14
15     /**
16      * @return the packetCount
17      */
18     public long getPacketCount() {
19         return packetCount;
20     }
21
22     /**
23      * @param packetCount
24      *            the packetCount to set
25      */
26     public void setPacketCount(long packetCount) {
27         this.packetCount = packetCount;
28     }
29
30     /**
31      * @return the byteCount
32      */
33     public long getByteCount() {
34         return byteCount;
35     }
36
37     /**
38      * @param byteCount
39      *            the byteCount to set
40      */
41     public void setByteCount(long byteCount) {
42         this.byteCount = byteCount;
43     }
44
45     /**
46      * @return the flowCount
47      */
48     public int getFlowCount() {
49         return flowCount;
50     }
51
52     /**
53      * @param flowCount
54      *            the flowCount to set
55      */
56     public void setFlowCount(int flowCount) {
57         this.flowCount = flowCount;
58     }
59
60     @Override
61     public int getLength() {
62         return 24;
63     }
64
65     @Override
66     public void readFrom(IDataBuffer data) {
67         this.packetCount = data.getLong();
68         this.byteCount = data.getLong();
69         this.flowCount = data.getInt();
70         data.getInt(); // pad
71     }
72
73     @Override
74     public void writeTo(IDataBuffer data) {
75         data.putLong(this.packetCount);
76         data.putLong(this.byteCount);
77         data.putInt(this.flowCount);
78         data.putInt(0); // pad
79     }
80
81     @Override
82     public int hashCode() {
83         final int prime = 397;
84         int result = 1;
85         result = prime * result + (int) (byteCount ^ (byteCount >>> 32));
86         result = prime * result + flowCount;
87         result = prime * result + (int) (packetCount ^ (packetCount >>> 32));
88         return result;
89     }
90
91     @Override
92     public boolean equals(Object obj) {
93         if (this == obj) {
94             return true;
95         }
96         if (obj == null) {
97             return false;
98         }
99         if (!(obj instanceof OFPAggregateStatisticsReply)) {
100             return false;
101         }
102         OFPAggregateStatisticsReply other = (OFPAggregateStatisticsReply) obj;
103         if (byteCount != other.byteCount) {
104             return false;
105         }
106         if (flowCount != other.flowCount) {
107             return false;
108         }
109         if (packetCount != other.packetCount) {
110             return false;
111         }
112         return true;
113     }
114 }