blob: 8175fa594cd7c637a439b3f53ae63f78ec4fd7a1 [file] [log] [blame]
tom7ef8ff92014-09-17 13:08:06 -07001// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2// Copyright (c) 2011, 2012 Open Networking Foundation
3// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4// This library was generated by the LoxiGen Compiler.
5// See the file LICENSE.txt which should have been included in the source distribution
6
7// Automatically generated by LOXI from template of_class.java
8// Do not modify
9
10package org.projectfloodlight.openflow.protocol.ver13;
11
12import org.projectfloodlight.openflow.protocol.*;
13import org.projectfloodlight.openflow.protocol.action.*;
14import org.projectfloodlight.openflow.protocol.actionid.*;
15import org.projectfloodlight.openflow.protocol.bsntlv.*;
16import org.projectfloodlight.openflow.protocol.errormsg.*;
17import org.projectfloodlight.openflow.protocol.meterband.*;
18import org.projectfloodlight.openflow.protocol.instruction.*;
19import org.projectfloodlight.openflow.protocol.instructionid.*;
20import org.projectfloodlight.openflow.protocol.match.*;
21import org.projectfloodlight.openflow.protocol.oxm.*;
22import org.projectfloodlight.openflow.protocol.queueprop.*;
23import org.projectfloodlight.openflow.types.*;
24import org.projectfloodlight.openflow.util.*;
25import org.projectfloodlight.openflow.exceptions.*;
26import org.slf4j.Logger;
27import org.slf4j.LoggerFactory;
28import java.util.Set;
29import org.jboss.netty.buffer.ChannelBuffer;
30import com.google.common.hash.PrimitiveSink;
31import com.google.common.hash.Funnel;
32
33class OFBsnGentableStatsEntryVer13 implements OFBsnGentableStatsEntry {
34 private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableStatsEntryVer13.class);
35 // version: 1.3
36 final static byte WIRE_VERSION = 4;
37 final static int LENGTH = 24;
38
39 private final static long DEFAULT_ENTRY_COUNT = 0x0L;
40 private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
41
42 // OF message fields
43 private final GenTableId tableId;
44 private final long entryCount;
45 private final U128 checksum;
46//
47
48 // package private constructor - used by readers, builders, and factory
49 OFBsnGentableStatsEntryVer13(GenTableId tableId, long entryCount, U128 checksum) {
50 this.tableId = tableId;
51 this.entryCount = entryCount;
52 this.checksum = checksum;
53 }
54
55 // Accessors for OF message fields
56 @Override
57 public GenTableId getTableId() {
58 return tableId;
59 }
60
61 @Override
62 public long getEntryCount() {
63 return entryCount;
64 }
65
66 @Override
67 public U128 getChecksum() {
68 return checksum;
69 }
70
71 @Override
72 public OFVersion getVersion() {
73 return OFVersion.OF_13;
74 }
75
76
77
78 public OFBsnGentableStatsEntry.Builder createBuilder() {
79 return new BuilderWithParent(this);
80 }
81
82 static class BuilderWithParent implements OFBsnGentableStatsEntry.Builder {
83 final OFBsnGentableStatsEntryVer13 parentMessage;
84
85 // OF message fields
86 private boolean tableIdSet;
87 private GenTableId tableId;
88 private boolean entryCountSet;
89 private long entryCount;
90 private boolean checksumSet;
91 private U128 checksum;
92
93 BuilderWithParent(OFBsnGentableStatsEntryVer13 parentMessage) {
94 this.parentMessage = parentMessage;
95 }
96
97 @Override
98 public GenTableId getTableId() {
99 return tableId;
100 }
101
102 @Override
103 public OFBsnGentableStatsEntry.Builder setTableId(GenTableId tableId) {
104 this.tableId = tableId;
105 this.tableIdSet = true;
106 return this;
107 }
108 @Override
109 public long getEntryCount() {
110 return entryCount;
111 }
112
113 @Override
114 public OFBsnGentableStatsEntry.Builder setEntryCount(long entryCount) {
115 this.entryCount = entryCount;
116 this.entryCountSet = true;
117 return this;
118 }
119 @Override
120 public U128 getChecksum() {
121 return checksum;
122 }
123
124 @Override
125 public OFBsnGentableStatsEntry.Builder setChecksum(U128 checksum) {
126 this.checksum = checksum;
127 this.checksumSet = true;
128 return this;
129 }
130 @Override
131 public OFVersion getVersion() {
132 return OFVersion.OF_13;
133 }
134
135
136
137 @Override
138 public OFBsnGentableStatsEntry build() {
139 GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
140 if(tableId == null)
141 throw new NullPointerException("Property tableId must not be null");
142 long entryCount = this.entryCountSet ? this.entryCount : parentMessage.entryCount;
143 U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
144 if(checksum == null)
145 throw new NullPointerException("Property checksum must not be null");
146
147 //
148 return new OFBsnGentableStatsEntryVer13(
149 tableId,
150 entryCount,
151 checksum
152 );
153 }
154
155 }
156
157 static class Builder implements OFBsnGentableStatsEntry.Builder {
158 // OF message fields
159 private boolean tableIdSet;
160 private GenTableId tableId;
161 private boolean entryCountSet;
162 private long entryCount;
163 private boolean checksumSet;
164 private U128 checksum;
165
166 @Override
167 public GenTableId getTableId() {
168 return tableId;
169 }
170
171 @Override
172 public OFBsnGentableStatsEntry.Builder setTableId(GenTableId tableId) {
173 this.tableId = tableId;
174 this.tableIdSet = true;
175 return this;
176 }
177 @Override
178 public long getEntryCount() {
179 return entryCount;
180 }
181
182 @Override
183 public OFBsnGentableStatsEntry.Builder setEntryCount(long entryCount) {
184 this.entryCount = entryCount;
185 this.entryCountSet = true;
186 return this;
187 }
188 @Override
189 public U128 getChecksum() {
190 return checksum;
191 }
192
193 @Override
194 public OFBsnGentableStatsEntry.Builder setChecksum(U128 checksum) {
195 this.checksum = checksum;
196 this.checksumSet = true;
197 return this;
198 }
199 @Override
200 public OFVersion getVersion() {
201 return OFVersion.OF_13;
202 }
203
204//
205 @Override
206 public OFBsnGentableStatsEntry build() {
207 if(!this.tableIdSet)
208 throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
209 if(tableId == null)
210 throw new NullPointerException("Property tableId must not be null");
211 long entryCount = this.entryCountSet ? this.entryCount : DEFAULT_ENTRY_COUNT;
212 U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
213 if(checksum == null)
214 throw new NullPointerException("Property checksum must not be null");
215
216
217 return new OFBsnGentableStatsEntryVer13(
218 tableId,
219 entryCount,
220 checksum
221 );
222 }
223
224 }
225
226
227 final static Reader READER = new Reader();
228 static class Reader implements OFMessageReader<OFBsnGentableStatsEntry> {
229 @Override
230 public OFBsnGentableStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
231 GenTableId tableId = GenTableId.read2Bytes(bb);
232 // pad: 2 bytes
233 bb.skipBytes(2);
234 long entryCount = U32.f(bb.readInt());
235 U128 checksum = U128.read16Bytes(bb);
236
237 OFBsnGentableStatsEntryVer13 bsnGentableStatsEntryVer13 = new OFBsnGentableStatsEntryVer13(
238 tableId,
239 entryCount,
240 checksum
241 );
242 if(logger.isTraceEnabled())
243 logger.trace("readFrom - read={}", bsnGentableStatsEntryVer13);
244 return bsnGentableStatsEntryVer13;
245 }
246 }
247
248 public void putTo(PrimitiveSink sink) {
249 FUNNEL.funnel(this, sink);
250 }
251
252 final static OFBsnGentableStatsEntryVer13Funnel FUNNEL = new OFBsnGentableStatsEntryVer13Funnel();
253 static class OFBsnGentableStatsEntryVer13Funnel implements Funnel<OFBsnGentableStatsEntryVer13> {
254 private static final long serialVersionUID = 1L;
255 @Override
256 public void funnel(OFBsnGentableStatsEntryVer13 message, PrimitiveSink sink) {
257 message.tableId.putTo(sink);
258 // skip pad (2 bytes)
259 sink.putLong(message.entryCount);
260 message.checksum.putTo(sink);
261 }
262 }
263
264
265 public void writeTo(ChannelBuffer bb) {
266 WRITER.write(bb, this);
267 }
268
269 final static Writer WRITER = new Writer();
270 static class Writer implements OFMessageWriter<OFBsnGentableStatsEntryVer13> {
271 @Override
272 public void write(ChannelBuffer bb, OFBsnGentableStatsEntryVer13 message) {
273 message.tableId.write2Bytes(bb);
274 // pad: 2 bytes
275 bb.writeZero(2);
276 bb.writeInt(U32.t(message.entryCount));
277 message.checksum.write16Bytes(bb);
278
279
280 }
281 }
282
283 @Override
284 public String toString() {
285 StringBuilder b = new StringBuilder("OFBsnGentableStatsEntryVer13(");
286 b.append("tableId=").append(tableId);
287 b.append(", ");
288 b.append("entryCount=").append(entryCount);
289 b.append(", ");
290 b.append("checksum=").append(checksum);
291 b.append(")");
292 return b.toString();
293 }
294
295 @Override
296 public boolean equals(Object obj) {
297 if (this == obj)
298 return true;
299 if (obj == null)
300 return false;
301 if (getClass() != obj.getClass())
302 return false;
303 OFBsnGentableStatsEntryVer13 other = (OFBsnGentableStatsEntryVer13) obj;
304
305 if (tableId == null) {
306 if (other.tableId != null)
307 return false;
308 } else if (!tableId.equals(other.tableId))
309 return false;
310 if( entryCount != other.entryCount)
311 return false;
312 if (checksum == null) {
313 if (other.checksum != null)
314 return false;
315 } else if (!checksum.equals(other.checksum))
316 return false;
317 return true;
318 }
319
320 @Override
321 public int hashCode() {
322 final int prime = 31;
323 int result = 1;
324
325 result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
326 result = prime * (int) (entryCount ^ (entryCount >>> 32));
327 result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
328 return result;
329 }
330
331}