Merge "Bug 2347: DOMConcurrentDataCommitCoordinator uses wrong phase name"
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / statistics / OFAggregateStatisticsRequest.java
1 package org.openflow.protocol.statistics;
2
3 import java.nio.ByteBuffer;
4
5 import org.openflow.protocol.OFMatch;
6
7 /**
8  * Represents an ofp_aggregate_stats_request structure
9  * @author David Erickson (daviderickson@cs.stanford.edu)
10  */
11 public class OFAggregateStatisticsRequest implements OFStatistics {
12     protected OFMatch match;
13     protected byte tableId;
14     protected short outPort;
15
16     /**
17      * @return the match
18      */
19     public OFMatch getMatch() {
20         return match;
21     }
22
23     /**
24      * @param match the match to set
25      */
26     public void setMatch(OFMatch match) {
27         this.match = match;
28     }
29
30     /**
31      * @return the tableId
32      */
33     public byte getTableId() {
34         return tableId;
35     }
36
37     /**
38      * @param tableId the tableId to set
39      */
40     public void setTableId(byte tableId) {
41         this.tableId = tableId;
42     }
43
44     /**
45      * @return the outPort
46      */
47     public short getOutPort() {
48         return outPort;
49     }
50
51     /**
52      * @param outPort the outPort to set
53      */
54     public void setOutPort(short outPort) {
55         this.outPort = outPort;
56     }
57
58     @Override
59     public int getLength() {
60         return 44;
61     }
62
63     @Override
64     public void readFrom(ByteBuffer data) {
65         if (this.match == null)
66             this.match = new OFMatch();
67         this.match.readFrom(data);
68         this.tableId = data.get();
69         data.get(); // pad
70         this.outPort = data.getShort();
71     }
72
73     @Override
74     public void writeTo(ByteBuffer data) {
75         this.match.writeTo(data);
76         data.put(this.tableId);
77         data.put((byte) 0);
78         data.putShort(this.outPort);
79     }
80
81     @Override
82     public int hashCode() {
83         final int prime = 401;
84         int result = 1;
85         result = prime * result + ((match == null) ? 0 : match.hashCode());
86         result = prime * result + outPort;
87         result = prime * result + tableId;
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 OFAggregateStatisticsRequest)) {
100             return false;
101         }
102         OFAggregateStatisticsRequest other = (OFAggregateStatisticsRequest) obj;
103         if (match == null) {
104             if (other.match != null) {
105                 return false;
106             }
107         } else if (!match.equals(other.match)) {
108             return false;
109         }
110         if (outPort != other.outPort) {
111             return false;
112         }
113         if (tableId != other.tableId) {
114             return false;
115         }
116         return true;
117     }
118 }