blob: 73a3fb4be4cbc27a65d25d8cb71d6deb0bea2cac [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;
32import java.util.Arrays;
33
34class OFBsnTlvCircuitIdVer13 implements OFBsnTlvCircuitId {
35 private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvCircuitIdVer13.class);
36 // version: 1.3
37 final static byte WIRE_VERSION = 4;
38 final static int MINIMUM_LENGTH = 4;
39
40 private final static byte[] DEFAULT_VALUE = new byte[0];
41
42 // OF message fields
43 private final byte[] value;
44//
45 // Immutable default instance
46 final static OFBsnTlvCircuitIdVer13 DEFAULT = new OFBsnTlvCircuitIdVer13(
47 DEFAULT_VALUE
48 );
49
50 // package private constructor - used by readers, builders, and factory
51 OFBsnTlvCircuitIdVer13(byte[] value) {
52 this.value = value;
53 }
54
55 // Accessors for OF message fields
56 @Override
57 public int getType() {
58 return 0xe;
59 }
60
61 @Override
62 public byte[] getValue() {
63 return value;
64 }
65
66 @Override
67 public OFVersion getVersion() {
68 return OFVersion.OF_13;
69 }
70
71
72
73 public OFBsnTlvCircuitId.Builder createBuilder() {
74 return new BuilderWithParent(this);
75 }
76
77 static class BuilderWithParent implements OFBsnTlvCircuitId.Builder {
78 final OFBsnTlvCircuitIdVer13 parentMessage;
79
80 // OF message fields
81 private boolean valueSet;
82 private byte[] value;
83
84 BuilderWithParent(OFBsnTlvCircuitIdVer13 parentMessage) {
85 this.parentMessage = parentMessage;
86 }
87
88 @Override
89 public int getType() {
90 return 0xe;
91 }
92
93 @Override
94 public byte[] getValue() {
95 return value;
96 }
97
98 @Override
99 public OFBsnTlvCircuitId.Builder setValue(byte[] value) {
100 this.value = value;
101 this.valueSet = true;
102 return this;
103 }
104 @Override
105 public OFVersion getVersion() {
106 return OFVersion.OF_13;
107 }
108
109
110
111 @Override
112 public OFBsnTlvCircuitId build() {
113 byte[] value = this.valueSet ? this.value : parentMessage.value;
114 if(value == null)
115 throw new NullPointerException("Property value must not be null");
116
117 //
118 return new OFBsnTlvCircuitIdVer13(
119 value
120 );
121 }
122
123 }
124
125 static class Builder implements OFBsnTlvCircuitId.Builder {
126 // OF message fields
127 private boolean valueSet;
128 private byte[] value;
129
130 @Override
131 public int getType() {
132 return 0xe;
133 }
134
135 @Override
136 public byte[] getValue() {
137 return value;
138 }
139
140 @Override
141 public OFBsnTlvCircuitId.Builder setValue(byte[] value) {
142 this.value = value;
143 this.valueSet = true;
144 return this;
145 }
146 @Override
147 public OFVersion getVersion() {
148 return OFVersion.OF_13;
149 }
150
151//
152 @Override
153 public OFBsnTlvCircuitId build() {
154 byte[] value = this.valueSet ? this.value : DEFAULT_VALUE;
155 if(value == null)
156 throw new NullPointerException("Property value must not be null");
157
158
159 return new OFBsnTlvCircuitIdVer13(
160 value
161 );
162 }
163
164 }
165
166
167 final static Reader READER = new Reader();
168 static class Reader implements OFMessageReader<OFBsnTlvCircuitId> {
169 @Override
170 public OFBsnTlvCircuitId readFrom(ChannelBuffer bb) throws OFParseError {
171 int start = bb.readerIndex();
172 // fixed value property type == 0xe
173 short type = bb.readShort();
174 if(type != (short) 0xe)
175 throw new OFParseError("Wrong type: Expected=0xe(0xe), got="+type);
176 int length = U16.f(bb.readShort());
177 if(length < MINIMUM_LENGTH)
178 throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
179 if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
180 // Buffer does not have all data yet
181 bb.readerIndex(start);
182 return null;
183 }
184 if(logger.isTraceEnabled())
185 logger.trace("readFrom - length={}", length);
186 byte[] value = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
187
188 OFBsnTlvCircuitIdVer13 bsnTlvCircuitIdVer13 = new OFBsnTlvCircuitIdVer13(
189 value
190 );
191 if(logger.isTraceEnabled())
192 logger.trace("readFrom - read={}", bsnTlvCircuitIdVer13);
193 return bsnTlvCircuitIdVer13;
194 }
195 }
196
197 public void putTo(PrimitiveSink sink) {
198 FUNNEL.funnel(this, sink);
199 }
200
201 final static OFBsnTlvCircuitIdVer13Funnel FUNNEL = new OFBsnTlvCircuitIdVer13Funnel();
202 static class OFBsnTlvCircuitIdVer13Funnel implements Funnel<OFBsnTlvCircuitIdVer13> {
203 private static final long serialVersionUID = 1L;
204 @Override
205 public void funnel(OFBsnTlvCircuitIdVer13 message, PrimitiveSink sink) {
206 // fixed value property type = 0xe
207 sink.putShort((short) 0xe);
208 // FIXME: skip funnel of length
209 sink.putBytes(message.value);
210 }
211 }
212
213
214 public void writeTo(ChannelBuffer bb) {
215 WRITER.write(bb, this);
216 }
217
218 final static Writer WRITER = new Writer();
219 static class Writer implements OFMessageWriter<OFBsnTlvCircuitIdVer13> {
220 @Override
221 public void write(ChannelBuffer bb, OFBsnTlvCircuitIdVer13 message) {
222 int startIndex = bb.writerIndex();
223 // fixed value property type = 0xe
224 bb.writeShort((short) 0xe);
225 // length is length of variable message, will be updated at the end
226 int lengthIndex = bb.writerIndex();
227 bb.writeShort(U16.t(0));
228
229 bb.writeBytes(message.value);
230
231 // update length field
232 int length = bb.writerIndex() - startIndex;
233 bb.setShort(lengthIndex, length);
234
235 }
236 }
237
238 @Override
239 public String toString() {
240 StringBuilder b = new StringBuilder("OFBsnTlvCircuitIdVer13(");
241 b.append("value=").append(Arrays.toString(value));
242 b.append(")");
243 return b.toString();
244 }
245
246 @Override
247 public boolean equals(Object obj) {
248 if (this == obj)
249 return true;
250 if (obj == null)
251 return false;
252 if (getClass() != obj.getClass())
253 return false;
254 OFBsnTlvCircuitIdVer13 other = (OFBsnTlvCircuitIdVer13) obj;
255
256 if (!Arrays.equals(value, other.value))
257 return false;
258 return true;
259 }
260
261 @Override
262 public int hashCode() {
263 final int prime = 31;
264 int result = 1;
265
266 result = prime * result + Arrays.hashCode(value);
267 return result;
268 }
269
270}