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