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