blob: 058b2b02f0cd66baadad835f406ea4b069f82fb9 [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -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 OFBsnGentableDescStatsEntryVer13 implements OFBsnGentableDescStatsEntry {
34 private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableDescStatsEntryVer13.class);
35 // version: 1.3
36 final static byte WIRE_VERSION = 4;
37 final static int LENGTH = 48;
38
39 private final static String DEFAULT_NAME = "";
40 private final static long DEFAULT_BUCKETS_SIZE = 0x0L;
41 private final static long DEFAULT_MAX_ENTRIES = 0x0L;
42
43 // OF message fields
44 private final GenTableId tableId;
45 private final String name;
46 private final long bucketsSize;
47 private final long maxEntries;
48//
49
50 // package private constructor - used by readers, builders, and factory
51 OFBsnGentableDescStatsEntryVer13(GenTableId tableId, String name, long bucketsSize, long maxEntries) {
52 this.tableId = tableId;
53 this.name = name;
54 this.bucketsSize = bucketsSize;
55 this.maxEntries = maxEntries;
56 }
57
58 // Accessors for OF message fields
59 @Override
60 public GenTableId getTableId() {
61 return tableId;
62 }
63
64 @Override
65 public String getName() {
66 return name;
67 }
68
69 @Override
70 public long getBucketsSize() {
71 return bucketsSize;
72 }
73
74 @Override
75 public long getMaxEntries() {
76 return maxEntries;
77 }
78
79 @Override
80 public OFVersion getVersion() {
81 return OFVersion.OF_13;
82 }
83
84
85
86 public OFBsnGentableDescStatsEntry.Builder createBuilder() {
87 return new BuilderWithParent(this);
88 }
89
90 static class BuilderWithParent implements OFBsnGentableDescStatsEntry.Builder {
91 final OFBsnGentableDescStatsEntryVer13 parentMessage;
92
93 // OF message fields
94 private boolean tableIdSet;
95 private GenTableId tableId;
96 private boolean nameSet;
97 private String name;
98 private boolean bucketsSizeSet;
99 private long bucketsSize;
100 private boolean maxEntriesSet;
101 private long maxEntries;
102
103 BuilderWithParent(OFBsnGentableDescStatsEntryVer13 parentMessage) {
104 this.parentMessage = parentMessage;
105 }
106
107 @Override
108 public GenTableId getTableId() {
109 return tableId;
110 }
111
112 @Override
113 public OFBsnGentableDescStatsEntry.Builder setTableId(GenTableId tableId) {
114 this.tableId = tableId;
115 this.tableIdSet = true;
116 return this;
117 }
118 @Override
119 public String getName() {
120 return name;
121 }
122
123 @Override
124 public OFBsnGentableDescStatsEntry.Builder setName(String name) {
125 this.name = name;
126 this.nameSet = true;
127 return this;
128 }
129 @Override
130 public long getBucketsSize() {
131 return bucketsSize;
132 }
133
134 @Override
135 public OFBsnGentableDescStatsEntry.Builder setBucketsSize(long bucketsSize) {
136 this.bucketsSize = bucketsSize;
137 this.bucketsSizeSet = true;
138 return this;
139 }
140 @Override
141 public long getMaxEntries() {
142 return maxEntries;
143 }
144
145 @Override
146 public OFBsnGentableDescStatsEntry.Builder setMaxEntries(long maxEntries) {
147 this.maxEntries = maxEntries;
148 this.maxEntriesSet = true;
149 return this;
150 }
151 @Override
152 public OFVersion getVersion() {
153 return OFVersion.OF_13;
154 }
155
156
157
158 @Override
159 public OFBsnGentableDescStatsEntry build() {
160 GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
161 if(tableId == null)
162 throw new NullPointerException("Property tableId must not be null");
163 String name = this.nameSet ? this.name : parentMessage.name;
164 if(name == null)
165 throw new NullPointerException("Property name must not be null");
166 long bucketsSize = this.bucketsSizeSet ? this.bucketsSize : parentMessage.bucketsSize;
167 long maxEntries = this.maxEntriesSet ? this.maxEntries : parentMessage.maxEntries;
168
169 //
170 return new OFBsnGentableDescStatsEntryVer13(
171 tableId,
172 name,
173 bucketsSize,
174 maxEntries
175 );
176 }
177
178 }
179
180 static class Builder implements OFBsnGentableDescStatsEntry.Builder {
181 // OF message fields
182 private boolean tableIdSet;
183 private GenTableId tableId;
184 private boolean nameSet;
185 private String name;
186 private boolean bucketsSizeSet;
187 private long bucketsSize;
188 private boolean maxEntriesSet;
189 private long maxEntries;
190
191 @Override
192 public GenTableId getTableId() {
193 return tableId;
194 }
195
196 @Override
197 public OFBsnGentableDescStatsEntry.Builder setTableId(GenTableId tableId) {
198 this.tableId = tableId;
199 this.tableIdSet = true;
200 return this;
201 }
202 @Override
203 public String getName() {
204 return name;
205 }
206
207 @Override
208 public OFBsnGentableDescStatsEntry.Builder setName(String name) {
209 this.name = name;
210 this.nameSet = true;
211 return this;
212 }
213 @Override
214 public long getBucketsSize() {
215 return bucketsSize;
216 }
217
218 @Override
219 public OFBsnGentableDescStatsEntry.Builder setBucketsSize(long bucketsSize) {
220 this.bucketsSize = bucketsSize;
221 this.bucketsSizeSet = true;
222 return this;
223 }
224 @Override
225 public long getMaxEntries() {
226 return maxEntries;
227 }
228
229 @Override
230 public OFBsnGentableDescStatsEntry.Builder setMaxEntries(long maxEntries) {
231 this.maxEntries = maxEntries;
232 this.maxEntriesSet = true;
233 return this;
234 }
235 @Override
236 public OFVersion getVersion() {
237 return OFVersion.OF_13;
238 }
239
240//
241 @Override
242 public OFBsnGentableDescStatsEntry build() {
243 if(!this.tableIdSet)
244 throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
245 if(tableId == null)
246 throw new NullPointerException("Property tableId must not be null");
247 String name = this.nameSet ? this.name : DEFAULT_NAME;
248 if(name == null)
249 throw new NullPointerException("Property name must not be null");
250 long bucketsSize = this.bucketsSizeSet ? this.bucketsSize : DEFAULT_BUCKETS_SIZE;
251 long maxEntries = this.maxEntriesSet ? this.maxEntries : DEFAULT_MAX_ENTRIES;
252
253
254 return new OFBsnGentableDescStatsEntryVer13(
255 tableId,
256 name,
257 bucketsSize,
258 maxEntries
259 );
260 }
261
262 }
263
264
265 final static Reader READER = new Reader();
266 static class Reader implements OFMessageReader<OFBsnGentableDescStatsEntry> {
267 @Override
268 public OFBsnGentableDescStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
269 int start = bb.readerIndex();
270 int length = U16.f(bb.readShort());
271 if(length != 48)
272 throw new OFParseError("Wrong length: Expected=48(48), got="+length);
273 if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
274 // Buffer does not have all data yet
275 bb.readerIndex(start);
276 return null;
277 }
278 if(logger.isTraceEnabled())
279 logger.trace("readFrom - length={}", length);
280 GenTableId tableId = GenTableId.read2Bytes(bb);
281 String name = ChannelUtils.readFixedLengthString(bb, 32);
282 long bucketsSize = U32.f(bb.readInt());
283 long maxEntries = U32.f(bb.readInt());
284 // pad: 4 bytes
285 bb.skipBytes(4);
286
287 OFBsnGentableDescStatsEntryVer13 bsnGentableDescStatsEntryVer13 = new OFBsnGentableDescStatsEntryVer13(
288 tableId,
289 name,
290 bucketsSize,
291 maxEntries
292 );
293 if(logger.isTraceEnabled())
294 logger.trace("readFrom - read={}", bsnGentableDescStatsEntryVer13);
295 return bsnGentableDescStatsEntryVer13;
296 }
297 }
298
299 public void putTo(PrimitiveSink sink) {
300 FUNNEL.funnel(this, sink);
301 }
302
303 final static OFBsnGentableDescStatsEntryVer13Funnel FUNNEL = new OFBsnGentableDescStatsEntryVer13Funnel();
304 static class OFBsnGentableDescStatsEntryVer13Funnel implements Funnel<OFBsnGentableDescStatsEntryVer13> {
305 private static final long serialVersionUID = 1L;
306 @Override
307 public void funnel(OFBsnGentableDescStatsEntryVer13 message, PrimitiveSink sink) {
308 // fixed value property length = 48
309 sink.putShort((short) 0x30);
310 message.tableId.putTo(sink);
311 sink.putUnencodedChars(message.name);
312 sink.putLong(message.bucketsSize);
313 sink.putLong(message.maxEntries);
314 // skip pad (4 bytes)
315 }
316 }
317
318
319 public void writeTo(ChannelBuffer bb) {
320 WRITER.write(bb, this);
321 }
322
323 final static Writer WRITER = new Writer();
324 static class Writer implements OFMessageWriter<OFBsnGentableDescStatsEntryVer13> {
325 @Override
326 public void write(ChannelBuffer bb, OFBsnGentableDescStatsEntryVer13 message) {
327 // fixed value property length = 48
328 bb.writeShort((short) 0x30);
329 message.tableId.write2Bytes(bb);
330 ChannelUtils.writeFixedLengthString(bb, message.name, 32);
331 bb.writeInt(U32.t(message.bucketsSize));
332 bb.writeInt(U32.t(message.maxEntries));
333 // pad: 4 bytes
334 bb.writeZero(4);
335
336
337 }
338 }
339
340 @Override
341 public String toString() {
342 StringBuilder b = new StringBuilder("OFBsnGentableDescStatsEntryVer13(");
343 b.append("tableId=").append(tableId);
344 b.append(", ");
345 b.append("name=").append(name);
346 b.append(", ");
347 b.append("bucketsSize=").append(bucketsSize);
348 b.append(", ");
349 b.append("maxEntries=").append(maxEntries);
350 b.append(")");
351 return b.toString();
352 }
353
354 @Override
355 public boolean equals(Object obj) {
356 if (this == obj)
357 return true;
358 if (obj == null)
359 return false;
360 if (getClass() != obj.getClass())
361 return false;
362 OFBsnGentableDescStatsEntryVer13 other = (OFBsnGentableDescStatsEntryVer13) obj;
363
364 if (tableId == null) {
365 if (other.tableId != null)
366 return false;
367 } else if (!tableId.equals(other.tableId))
368 return false;
369 if (name == null) {
370 if (other.name != null)
371 return false;
372 } else if (!name.equals(other.name))
373 return false;
374 if( bucketsSize != other.bucketsSize)
375 return false;
376 if( maxEntries != other.maxEntries)
377 return false;
378 return true;
379 }
380
381 @Override
382 public int hashCode() {
383 final int prime = 31;
384 int result = 1;
385
386 result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
387 result = prime * result + ((name == null) ? 0 : name.hashCode());
388 result = prime * (int) (bucketsSize ^ (bucketsSize >>> 32));
389 result = prime * (int) (maxEntries ^ (maxEntries >>> 32));
390 return result;
391 }
392
393}