Fix checkstyle warnings in netconf-cli
[controller.git] / third-party / openflowj / src / main / java / org / openflow / protocol / statistics / OFTableStatistics.java
1 package org.openflow.protocol.statistics;
2
3 import java.io.Serializable;
4 import java.nio.ByteBuffer;
5
6 import org.openflow.util.StringByteSerializer;
7
8 /**
9  * Represents an ofp_table_stats structure
10  * @author David Erickson (daviderickson@cs.stanford.edu)
11  */
12 public class OFTableStatistics implements OFStatistics, Serializable {
13     public static int MAX_TABLE_NAME_LEN = 32;
14
15     protected byte tableId;
16     protected String name;
17     protected int wildcards;
18     protected int maximumEntries;
19     protected int activeCount;
20     protected long lookupCount;
21     protected long matchedCount;
22
23     /**
24      * @return the tableId
25      */
26     public byte getTableId() {
27         return tableId;
28     }
29
30     /**
31      * @param tableId the tableId to set
32      */
33     public void setTableId(byte tableId) {
34         this.tableId = tableId;
35     }
36
37     /**
38      * @return the name
39      */
40     public String getName() {
41         return name;
42     }
43
44     /**
45      * @param name the name to set
46      */
47     public void setName(String name) {
48         this.name = name;
49     }
50
51     /**
52      * @return the wildcards
53      */
54     public int getWildcards() {
55         return wildcards;
56     }
57
58     /**
59      * @param wildcards the wildcards to set
60      */
61     public void setWildcards(int wildcards) {
62         this.wildcards = wildcards;
63     }
64
65     /**
66      * @return the maximumEntries
67      */
68     public int getMaximumEntries() {
69         return maximumEntries;
70     }
71
72     /**
73      * @param maximumEntries the maximumEntries to set
74      */
75     public void setMaximumEntries(int maximumEntries) {
76         this.maximumEntries = maximumEntries;
77     }
78
79     /**
80      * @return the activeCount
81      */
82     public int getActiveCount() {
83         return activeCount;
84     }
85
86     /**
87      * @param activeCount the activeCount to set
88      */
89     public void setActiveCount(int activeCount) {
90         this.activeCount = activeCount;
91     }
92
93     /**
94      * @return the lookupCount
95      */
96     public long getLookupCount() {
97         return lookupCount;
98     }
99
100     /**
101      * @param lookupCount the lookupCount to set
102      */
103     public void setLookupCount(long lookupCount) {
104         this.lookupCount = lookupCount;
105     }
106
107     /**
108      * @return the matchedCount
109      */
110     public long getMatchedCount() {
111         return matchedCount;
112     }
113
114     /**
115      * @param matchedCount the matchedCount to set
116      */
117     public void setMatchedCount(long matchedCount) {
118         this.matchedCount = matchedCount;
119     }
120
121     @Override
122     public int getLength() {
123         return 64;
124     }
125
126     @Override
127     public void readFrom(ByteBuffer data) {
128         this.tableId = data.get();
129         data.get(); // pad
130         data.get(); // pad
131         data.get(); // pad
132         this.name = StringByteSerializer.readFrom(data, MAX_TABLE_NAME_LEN);
133         this.wildcards = data.getInt();
134         this.maximumEntries = data.getInt();
135         this.activeCount = data.getInt();
136         this.lookupCount = data.getLong();
137         this.matchedCount = data.getLong();
138     }
139
140     @Override
141     public void writeTo(ByteBuffer data) {
142         data.put(this.tableId);
143         data.put((byte) 0); // pad
144         data.put((byte) 0); // pad
145         data.put((byte) 0); // pad
146         StringByteSerializer.writeTo(data, MAX_TABLE_NAME_LEN, this.name);
147         data.putInt(this.wildcards);
148         data.putInt(this.maximumEntries);
149         data.putInt(this.activeCount);
150         data.putLong(this.lookupCount);
151         data.putLong(this.matchedCount);
152     }
153
154     @Override
155     public int hashCode() {
156         final int prime = 449;
157         int result = 1;
158         result = prime * result + activeCount;
159         result = prime * result + (int) (lookupCount ^ (lookupCount >>> 32));
160         result = prime * result + (int) (matchedCount ^ (matchedCount >>> 32));
161         result = prime * result + maximumEntries;
162         result = prime * result + ((name == null) ? 0 : name.hashCode());
163         result = prime * result + tableId;
164         result = prime * result + wildcards;
165         return result;
166     }
167
168     @Override
169     public boolean equals(Object obj) {
170         if (this == obj) {
171             return true;
172         }
173         if (obj == null) {
174             return false;
175         }
176         if (!(obj instanceof OFTableStatistics)) {
177             return false;
178         }
179         OFTableStatistics other = (OFTableStatistics) obj;
180         if (activeCount != other.activeCount) {
181             return false;
182         }
183         if (lookupCount != other.lookupCount) {
184             return false;
185         }
186         if (matchedCount != other.matchedCount) {
187             return false;
188         }
189         if (maximumEntries != other.maximumEntries) {
190             return false;
191         }
192         if (name == null) {
193             if (other.name != null) {
194                 return false;
195             }
196         } else if (!name.equals(other.name)) {
197             return false;
198         }
199         if (tableId != other.tableId) {
200             return false;
201         }
202         if (wildcards != other.wildcards) {
203             return false;
204         }
205         return true;
206     }
207 }