blob: 61986e3e6bc7f6b1368aa0405e36cd8623bfc9a4 [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.ver12;
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 OFOxmBsnUdf2MaskedVer12 implements OFOxmBsnUdf2Masked {
34 private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf2MaskedVer12.class);
35 // version: 1.2
36 final static byte WIRE_VERSION = 3;
37 final static int LENGTH = 12;
38
39 private final static UDF DEFAULT_VALUE = UDF.ZERO;
40 private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
41
42 // OF message fields
43 private final UDF value;
44 private final UDF mask;
45//
46 // Immutable default instance
47 final static OFOxmBsnUdf2MaskedVer12 DEFAULT = new OFOxmBsnUdf2MaskedVer12(
48 DEFAULT_VALUE, DEFAULT_VALUE_MASK
49 );
50
51 // package private constructor - used by readers, builders, and factory
52 OFOxmBsnUdf2MaskedVer12(UDF value, UDF mask) {
53 this.value = value;
54 this.mask = mask;
55 }
56
57 // Accessors for OF message fields
58 @Override
59 public long getTypeLen() {
60 return 0x31508L;
61 }
62
63 @Override
64 public UDF getValue() {
65 return value;
66 }
67
68 @Override
69 public UDF getMask() {
70 return mask;
71 }
72
73 @Override
74 public MatchField<UDF> getMatchField() {
75 return MatchField.BSN_UDF2;
76 }
77
78 @Override
79 public boolean isMasked() {
80 return true;
81 }
82
83 public OFOxm<UDF> getCanonical() {
84 if (UDF.NO_MASK.equals(mask)) {
85 return new OFOxmBsnUdf2Ver12(value);
86 } else if(UDF.FULL_MASK.equals(mask)) {
87 return null;
88 } else {
89 return this;
90 }
91 }
92
93 @Override
94 public OFVersion getVersion() {
95 return OFVersion.OF_12;
96 }
97
98
99
100 public OFOxmBsnUdf2Masked.Builder createBuilder() {
101 return new BuilderWithParent(this);
102 }
103
104 static class BuilderWithParent implements OFOxmBsnUdf2Masked.Builder {
105 final OFOxmBsnUdf2MaskedVer12 parentMessage;
106
107 // OF message fields
108 private boolean valueSet;
109 private UDF value;
110 private boolean maskSet;
111 private UDF mask;
112
113 BuilderWithParent(OFOxmBsnUdf2MaskedVer12 parentMessage) {
114 this.parentMessage = parentMessage;
115 }
116
117 @Override
118 public long getTypeLen() {
119 return 0x31508L;
120 }
121
122 @Override
123 public UDF getValue() {
124 return value;
125 }
126
127 @Override
128 public OFOxmBsnUdf2Masked.Builder setValue(UDF value) {
129 this.value = value;
130 this.valueSet = true;
131 return this;
132 }
133 @Override
134 public UDF getMask() {
135 return mask;
136 }
137
138 @Override
139 public OFOxmBsnUdf2Masked.Builder setMask(UDF mask) {
140 this.mask = mask;
141 this.maskSet = true;
142 return this;
143 }
144 @Override
145 public MatchField<UDF> getMatchField() {
146 return MatchField.BSN_UDF2;
147 }
148
149 @Override
150 public boolean isMasked() {
151 return true;
152 }
153
154 @Override
155 public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
156 throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
157 }
158
159 @Override
160 public OFVersion getVersion() {
161 return OFVersion.OF_12;
162 }
163
164
165
166 @Override
167 public OFOxmBsnUdf2Masked build() {
168 UDF value = this.valueSet ? this.value : parentMessage.value;
169 if(value == null)
170 throw new NullPointerException("Property value must not be null");
171 UDF mask = this.maskSet ? this.mask : parentMessage.mask;
172 if(mask == null)
173 throw new NullPointerException("Property mask must not be null");
174
175 //
176 return new OFOxmBsnUdf2MaskedVer12(
177 value,
178 mask
179 );
180 }
181
182 }
183
184 static class Builder implements OFOxmBsnUdf2Masked.Builder {
185 // OF message fields
186 private boolean valueSet;
187 private UDF value;
188 private boolean maskSet;
189 private UDF mask;
190
191 @Override
192 public long getTypeLen() {
193 return 0x31508L;
194 }
195
196 @Override
197 public UDF getValue() {
198 return value;
199 }
200
201 @Override
202 public OFOxmBsnUdf2Masked.Builder setValue(UDF value) {
203 this.value = value;
204 this.valueSet = true;
205 return this;
206 }
207 @Override
208 public UDF getMask() {
209 return mask;
210 }
211
212 @Override
213 public OFOxmBsnUdf2Masked.Builder setMask(UDF mask) {
214 this.mask = mask;
215 this.maskSet = true;
216 return this;
217 }
218 @Override
219 public MatchField<UDF> getMatchField() {
220 return MatchField.BSN_UDF2;
221 }
222
223 @Override
224 public boolean isMasked() {
225 return true;
226 }
227
228 @Override
229 public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
230 throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
231 }
232
233 @Override
234 public OFVersion getVersion() {
235 return OFVersion.OF_12;
236 }
237
238//
239 @Override
240 public OFOxmBsnUdf2Masked build() {
241 UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
242 if(value == null)
243 throw new NullPointerException("Property value must not be null");
244 UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
245 if(mask == null)
246 throw new NullPointerException("Property mask must not be null");
247
248
249 return new OFOxmBsnUdf2MaskedVer12(
250 value,
251 mask
252 );
253 }
254
255 }
256
257
258 final static Reader READER = new Reader();
259 static class Reader implements OFMessageReader<OFOxmBsnUdf2Masked> {
260 @Override
261 public OFOxmBsnUdf2Masked readFrom(ChannelBuffer bb) throws OFParseError {
262 // fixed value property typeLen == 0x31508L
263 int typeLen = bb.readInt();
264 if(typeLen != 0x31508)
265 throw new OFParseError("Wrong typeLen: Expected=0x31508L(0x31508L), got="+typeLen);
266 UDF value = UDF.read4Bytes(bb);
267 UDF mask = UDF.read4Bytes(bb);
268
269 OFOxmBsnUdf2MaskedVer12 oxmBsnUdf2MaskedVer12 = new OFOxmBsnUdf2MaskedVer12(
270 value,
271 mask
272 );
273 if(logger.isTraceEnabled())
274 logger.trace("readFrom - read={}", oxmBsnUdf2MaskedVer12);
275 return oxmBsnUdf2MaskedVer12;
276 }
277 }
278
279 public void putTo(PrimitiveSink sink) {
280 FUNNEL.funnel(this, sink);
281 }
282
283 final static OFOxmBsnUdf2MaskedVer12Funnel FUNNEL = new OFOxmBsnUdf2MaskedVer12Funnel();
284 static class OFOxmBsnUdf2MaskedVer12Funnel implements Funnel<OFOxmBsnUdf2MaskedVer12> {
285 private static final long serialVersionUID = 1L;
286 @Override
287 public void funnel(OFOxmBsnUdf2MaskedVer12 message, PrimitiveSink sink) {
288 // fixed value property typeLen = 0x31508L
289 sink.putInt(0x31508);
290 message.value.putTo(sink);
291 message.mask.putTo(sink);
292 }
293 }
294
295
296 public void writeTo(ChannelBuffer bb) {
297 WRITER.write(bb, this);
298 }
299
300 final static Writer WRITER = new Writer();
301 static class Writer implements OFMessageWriter<OFOxmBsnUdf2MaskedVer12> {
302 @Override
303 public void write(ChannelBuffer bb, OFOxmBsnUdf2MaskedVer12 message) {
304 // fixed value property typeLen = 0x31508L
305 bb.writeInt(0x31508);
306 message.value.write4Bytes(bb);
307 message.mask.write4Bytes(bb);
308
309
310 }
311 }
312
313 @Override
314 public String toString() {
315 StringBuilder b = new StringBuilder("OFOxmBsnUdf2MaskedVer12(");
316 b.append("value=").append(value);
317 b.append(", ");
318 b.append("mask=").append(mask);
319 b.append(")");
320 return b.toString();
321 }
322
323 @Override
324 public boolean equals(Object obj) {
325 if (this == obj)
326 return true;
327 if (obj == null)
328 return false;
329 if (getClass() != obj.getClass())
330 return false;
331 OFOxmBsnUdf2MaskedVer12 other = (OFOxmBsnUdf2MaskedVer12) obj;
332
333 if (value == null) {
334 if (other.value != null)
335 return false;
336 } else if (!value.equals(other.value))
337 return false;
338 if (mask == null) {
339 if (other.mask != null)
340 return false;
341 } else if (!mask.equals(other.mask))
342 return false;
343 return true;
344 }
345
346 @Override
347 public int hashCode() {
348 final int prime = 31;
349 int result = 1;
350
351 result = prime * result + ((value == null) ? 0 : value.hashCode());
352 result = prime * result + ((mask == null) ? 0 : mask.hashCode());
353 return result;
354 }
355
356}