Umesh Krishnaswamy | 9b5c59e | 2012-12-27 19:39:51 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Autogenerated by Thrift Compiler (0.7.0) |
| 3 | * |
| 4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING |
| 5 | */ |
| 6 | package net.floodlightcontroller.packetstreamer.thrift; |
| 7 | |
| 8 | import java.util.List; |
| 9 | import java.util.ArrayList; |
| 10 | import java.util.Map; |
| 11 | import java.util.HashMap; |
| 12 | import java.util.EnumMap; |
| 13 | import java.util.Set; |
| 14 | import java.util.HashSet; |
| 15 | import java.util.EnumSet; |
| 16 | import java.util.Collections; |
| 17 | import java.util.BitSet; |
| 18 | import java.nio.ByteBuffer; |
| 19 | import java.util.Arrays; |
| 20 | import org.slf4j.Logger; |
| 21 | import org.slf4j.LoggerFactory; |
| 22 | |
| 23 | @SuppressWarnings("all") public class Packet implements org.apache.thrift.TBase<Packet, Packet._Fields>, java.io.Serializable, Cloneable { |
| 24 | private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Packet"); |
| 25 | |
| 26 | private static final org.apache.thrift.protocol.TField MESSAGE_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("messageType", org.apache.thrift.protocol.TType.I32, (short)1); |
| 27 | private static final org.apache.thrift.protocol.TField SW_PORT_TUPLE_FIELD_DESC = new org.apache.thrift.protocol.TField("swPortTuple", org.apache.thrift.protocol.TType.STRUCT, (short)2); |
| 28 | private static final org.apache.thrift.protocol.TField DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("data", org.apache.thrift.protocol.TType.STRING, (short)3); |
| 29 | |
| 30 | /** |
| 31 | * |
| 32 | * @see OFMessageType |
| 33 | */ |
| 34 | public OFMessageType messageType; // required |
| 35 | public SwitchPortTuple swPortTuple; // required |
| 36 | public ByteBuffer data; // required |
| 37 | |
| 38 | /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ |
| 39 | public enum _Fields implements org.apache.thrift.TFieldIdEnum { |
| 40 | /** |
| 41 | * |
| 42 | * @see OFMessageType |
| 43 | */ |
| 44 | MESSAGE_TYPE((short)1, "messageType"), |
| 45 | SW_PORT_TUPLE((short)2, "swPortTuple"), |
| 46 | DATA((short)3, "data"); |
| 47 | |
| 48 | private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); |
| 49 | |
| 50 | static { |
| 51 | for (_Fields field : EnumSet.allOf(_Fields.class)) { |
| 52 | byName.put(field.getFieldName(), field); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Find the _Fields constant that matches fieldId, or null if its not found. |
| 58 | */ |
| 59 | public static _Fields findByThriftId(int fieldId) { |
| 60 | switch(fieldId) { |
| 61 | case 1: // MESSAGE_TYPE |
| 62 | return MESSAGE_TYPE; |
| 63 | case 2: // SW_PORT_TUPLE |
| 64 | return SW_PORT_TUPLE; |
| 65 | case 3: // DATA |
| 66 | return DATA; |
| 67 | default: |
| 68 | return null; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Find the _Fields constant that matches fieldId, throwing an exception |
| 74 | * if it is not found. |
| 75 | */ |
| 76 | public static _Fields findByThriftIdOrThrow(int fieldId) { |
| 77 | _Fields fields = findByThriftId(fieldId); |
| 78 | if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); |
| 79 | return fields; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Find the _Fields constant that matches name, or null if its not found. |
| 84 | */ |
| 85 | public static _Fields findByName(String name) { |
| 86 | return byName.get(name); |
| 87 | } |
| 88 | |
| 89 | private final short _thriftId; |
| 90 | private final String _fieldName; |
| 91 | |
| 92 | _Fields(short thriftId, String fieldName) { |
| 93 | _thriftId = thriftId; |
| 94 | _fieldName = fieldName; |
| 95 | } |
| 96 | |
| 97 | public short getThriftFieldId() { |
| 98 | return _thriftId; |
| 99 | } |
| 100 | |
| 101 | public String getFieldName() { |
| 102 | return _fieldName; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | // isset id assignments |
| 107 | |
| 108 | public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; |
| 109 | static { |
| 110 | Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); |
| 111 | tmpMap.put(_Fields.MESSAGE_TYPE, new org.apache.thrift.meta_data.FieldMetaData("messageType", org.apache.thrift.TFieldRequirementType.DEFAULT, |
| 112 | new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, OFMessageType.class))); |
| 113 | tmpMap.put(_Fields.SW_PORT_TUPLE, new org.apache.thrift.meta_data.FieldMetaData("swPortTuple", org.apache.thrift.TFieldRequirementType.DEFAULT, |
| 114 | new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, SwitchPortTuple.class))); |
| 115 | tmpMap.put(_Fields.DATA, new org.apache.thrift.meta_data.FieldMetaData("data", org.apache.thrift.TFieldRequirementType.DEFAULT, |
| 116 | new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); |
| 117 | metaDataMap = Collections.unmodifiableMap(tmpMap); |
| 118 | org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Packet.class, metaDataMap); |
| 119 | } |
| 120 | |
| 121 | public Packet() { |
| 122 | } |
| 123 | |
| 124 | public Packet( |
| 125 | OFMessageType messageType, |
| 126 | SwitchPortTuple swPortTuple, |
| 127 | ByteBuffer data) |
| 128 | { |
| 129 | this(); |
| 130 | this.messageType = messageType; |
| 131 | this.swPortTuple = swPortTuple; |
| 132 | this.data = data; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Performs a deep copy on <i>other</i>. |
| 137 | */ |
| 138 | public Packet(Packet other) { |
| 139 | if (other.isSetMessageType()) { |
| 140 | this.messageType = other.messageType; |
| 141 | } |
| 142 | if (other.isSetSwPortTuple()) { |
| 143 | this.swPortTuple = new SwitchPortTuple(other.swPortTuple); |
| 144 | } |
| 145 | if (other.isSetData()) { |
| 146 | this.data = org.apache.thrift.TBaseHelper.copyBinary(other.data); |
| 147 | ; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | public Packet deepCopy() { |
| 152 | return new Packet(this); |
| 153 | } |
| 154 | |
| 155 | @Override |
| 156 | public void clear() { |
| 157 | this.messageType = null; |
| 158 | this.swPortTuple = null; |
| 159 | this.data = null; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * |
| 164 | * @see OFMessageType |
| 165 | */ |
| 166 | public OFMessageType getMessageType() { |
| 167 | return this.messageType; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * |
| 172 | * @see OFMessageType |
| 173 | */ |
| 174 | public Packet setMessageType(OFMessageType messageType) { |
| 175 | this.messageType = messageType; |
| 176 | return this; |
| 177 | } |
| 178 | |
| 179 | public void unsetMessageType() { |
| 180 | this.messageType = null; |
| 181 | } |
| 182 | |
| 183 | /** Returns true if field messageType is set (has been assigned a value) and false otherwise */ |
| 184 | public boolean isSetMessageType() { |
| 185 | return this.messageType != null; |
| 186 | } |
| 187 | |
| 188 | public void setMessageTypeIsSet(boolean value) { |
| 189 | if (!value) { |
| 190 | this.messageType = null; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | public SwitchPortTuple getSwPortTuple() { |
| 195 | return this.swPortTuple; |
| 196 | } |
| 197 | |
| 198 | public Packet setSwPortTuple(SwitchPortTuple swPortTuple) { |
| 199 | this.swPortTuple = swPortTuple; |
| 200 | return this; |
| 201 | } |
| 202 | |
| 203 | public void unsetSwPortTuple() { |
| 204 | this.swPortTuple = null; |
| 205 | } |
| 206 | |
| 207 | /** Returns true if field swPortTuple is set (has been assigned a value) and false otherwise */ |
| 208 | public boolean isSetSwPortTuple() { |
| 209 | return this.swPortTuple != null; |
| 210 | } |
| 211 | |
| 212 | public void setSwPortTupleIsSet(boolean value) { |
| 213 | if (!value) { |
| 214 | this.swPortTuple = null; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | public byte[] getData() { |
| 219 | setData(org.apache.thrift.TBaseHelper.rightSize(data)); |
| 220 | return data == null ? null : data.array(); |
| 221 | } |
| 222 | |
| 223 | public ByteBuffer bufferForData() { |
| 224 | return data; |
| 225 | } |
| 226 | |
| 227 | public Packet setData(byte[] data) { |
| 228 | setData(data == null ? (ByteBuffer)null : ByteBuffer.wrap(data)); |
| 229 | return this; |
| 230 | } |
| 231 | |
| 232 | public Packet setData(ByteBuffer data) { |
| 233 | this.data = data; |
| 234 | return this; |
| 235 | } |
| 236 | |
| 237 | public void unsetData() { |
| 238 | this.data = null; |
| 239 | } |
| 240 | |
| 241 | /** Returns true if field data is set (has been assigned a value) and false otherwise */ |
| 242 | public boolean isSetData() { |
| 243 | return this.data != null; |
| 244 | } |
| 245 | |
| 246 | public void setDataIsSet(boolean value) { |
| 247 | if (!value) { |
| 248 | this.data = null; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | public void setFieldValue(_Fields field, Object value) { |
| 253 | switch (field) { |
| 254 | case MESSAGE_TYPE: |
| 255 | if (value == null) { |
| 256 | unsetMessageType(); |
| 257 | } else { |
| 258 | setMessageType((OFMessageType)value); |
| 259 | } |
| 260 | break; |
| 261 | |
| 262 | case SW_PORT_TUPLE: |
| 263 | if (value == null) { |
| 264 | unsetSwPortTuple(); |
| 265 | } else { |
| 266 | setSwPortTuple((SwitchPortTuple)value); |
| 267 | } |
| 268 | break; |
| 269 | |
| 270 | case DATA: |
| 271 | if (value == null) { |
| 272 | unsetData(); |
| 273 | } else { |
| 274 | setData((ByteBuffer)value); |
| 275 | } |
| 276 | break; |
| 277 | |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | public Object getFieldValue(_Fields field) { |
| 282 | switch (field) { |
| 283 | case MESSAGE_TYPE: |
| 284 | return getMessageType(); |
| 285 | |
| 286 | case SW_PORT_TUPLE: |
| 287 | return getSwPortTuple(); |
| 288 | |
| 289 | case DATA: |
| 290 | return getData(); |
| 291 | |
| 292 | } |
| 293 | throw new IllegalStateException(); |
| 294 | } |
| 295 | |
| 296 | /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ |
| 297 | public boolean isSet(_Fields field) { |
| 298 | if (field == null) { |
| 299 | throw new IllegalArgumentException(); |
| 300 | } |
| 301 | |
| 302 | switch (field) { |
| 303 | case MESSAGE_TYPE: |
| 304 | return isSetMessageType(); |
| 305 | case SW_PORT_TUPLE: |
| 306 | return isSetSwPortTuple(); |
| 307 | case DATA: |
| 308 | return isSetData(); |
| 309 | } |
| 310 | throw new IllegalStateException(); |
| 311 | } |
| 312 | |
| 313 | @Override |
| 314 | public boolean equals(Object that) { |
| 315 | if (that == null) |
| 316 | return false; |
| 317 | if (that instanceof Packet) |
| 318 | return this.equals((Packet)that); |
| 319 | return false; |
| 320 | } |
| 321 | |
| 322 | public boolean equals(Packet that) { |
| 323 | if (that == null) |
| 324 | return false; |
| 325 | |
| 326 | boolean this_present_messageType = true && this.isSetMessageType(); |
| 327 | boolean that_present_messageType = true && that.isSetMessageType(); |
| 328 | if (this_present_messageType || that_present_messageType) { |
| 329 | if (!(this_present_messageType && that_present_messageType)) |
| 330 | return false; |
| 331 | if (!this.messageType.equals(that.messageType)) |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | boolean this_present_swPortTuple = true && this.isSetSwPortTuple(); |
| 336 | boolean that_present_swPortTuple = true && that.isSetSwPortTuple(); |
| 337 | if (this_present_swPortTuple || that_present_swPortTuple) { |
| 338 | if (!(this_present_swPortTuple && that_present_swPortTuple)) |
| 339 | return false; |
| 340 | if (!this.swPortTuple.equals(that.swPortTuple)) |
| 341 | return false; |
| 342 | } |
| 343 | |
| 344 | boolean this_present_data = true && this.isSetData(); |
| 345 | boolean that_present_data = true && that.isSetData(); |
| 346 | if (this_present_data || that_present_data) { |
| 347 | if (!(this_present_data && that_present_data)) |
| 348 | return false; |
| 349 | if (!this.data.equals(that.data)) |
| 350 | return false; |
| 351 | } |
| 352 | |
| 353 | return true; |
| 354 | } |
| 355 | |
| 356 | @Override |
| 357 | public int hashCode() { |
| 358 | return 0; |
| 359 | } |
| 360 | |
| 361 | public int compareTo(Packet other) { |
| 362 | if (!getClass().equals(other.getClass())) { |
| 363 | return getClass().getName().compareTo(other.getClass().getName()); |
| 364 | } |
| 365 | |
| 366 | int lastComparison = 0; |
| 367 | Packet typedOther = (Packet)other; |
| 368 | |
| 369 | lastComparison = Boolean.valueOf(isSetMessageType()).compareTo(typedOther.isSetMessageType()); |
| 370 | if (lastComparison != 0) { |
| 371 | return lastComparison; |
| 372 | } |
| 373 | if (isSetMessageType()) { |
| 374 | lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.messageType, typedOther.messageType); |
| 375 | if (lastComparison != 0) { |
| 376 | return lastComparison; |
| 377 | } |
| 378 | } |
| 379 | lastComparison = Boolean.valueOf(isSetSwPortTuple()).compareTo(typedOther.isSetSwPortTuple()); |
| 380 | if (lastComparison != 0) { |
| 381 | return lastComparison; |
| 382 | } |
| 383 | if (isSetSwPortTuple()) { |
| 384 | lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.swPortTuple, typedOther.swPortTuple); |
| 385 | if (lastComparison != 0) { |
| 386 | return lastComparison; |
| 387 | } |
| 388 | } |
| 389 | lastComparison = Boolean.valueOf(isSetData()).compareTo(typedOther.isSetData()); |
| 390 | if (lastComparison != 0) { |
| 391 | return lastComparison; |
| 392 | } |
| 393 | if (isSetData()) { |
| 394 | lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.data, typedOther.data); |
| 395 | if (lastComparison != 0) { |
| 396 | return lastComparison; |
| 397 | } |
| 398 | } |
| 399 | return 0; |
| 400 | } |
| 401 | |
| 402 | public _Fields fieldForId(int fieldId) { |
| 403 | return _Fields.findByThriftId(fieldId); |
| 404 | } |
| 405 | |
| 406 | public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { |
| 407 | org.apache.thrift.protocol.TField field; |
| 408 | iprot.readStructBegin(); |
| 409 | while (true) |
| 410 | { |
| 411 | field = iprot.readFieldBegin(); |
| 412 | if (field.type == org.apache.thrift.protocol.TType.STOP) { |
| 413 | break; |
| 414 | } |
| 415 | switch (field.id) { |
| 416 | case 1: // MESSAGE_TYPE |
| 417 | if (field.type == org.apache.thrift.protocol.TType.I32) { |
| 418 | this.messageType = OFMessageType.findByValue(iprot.readI32()); |
| 419 | } else { |
| 420 | org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); |
| 421 | } |
| 422 | break; |
| 423 | case 2: // SW_PORT_TUPLE |
| 424 | if (field.type == org.apache.thrift.protocol.TType.STRUCT) { |
| 425 | this.swPortTuple = new SwitchPortTuple(); |
| 426 | this.swPortTuple.read(iprot); |
| 427 | } else { |
| 428 | org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); |
| 429 | } |
| 430 | break; |
| 431 | case 3: // DATA |
| 432 | if (field.type == org.apache.thrift.protocol.TType.STRING) { |
| 433 | this.data = iprot.readBinary(); |
| 434 | } else { |
| 435 | org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); |
| 436 | } |
| 437 | break; |
| 438 | default: |
| 439 | org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); |
| 440 | } |
| 441 | iprot.readFieldEnd(); |
| 442 | } |
| 443 | iprot.readStructEnd(); |
| 444 | |
| 445 | // check for required fields of primitive type, which can't be checked in the validate method |
| 446 | validate(); |
| 447 | } |
| 448 | |
| 449 | public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { |
| 450 | validate(); |
| 451 | |
| 452 | oprot.writeStructBegin(STRUCT_DESC); |
| 453 | if (this.messageType != null) { |
| 454 | oprot.writeFieldBegin(MESSAGE_TYPE_FIELD_DESC); |
| 455 | oprot.writeI32(this.messageType.getValue()); |
| 456 | oprot.writeFieldEnd(); |
| 457 | } |
| 458 | if (this.swPortTuple != null) { |
| 459 | oprot.writeFieldBegin(SW_PORT_TUPLE_FIELD_DESC); |
| 460 | this.swPortTuple.write(oprot); |
| 461 | oprot.writeFieldEnd(); |
| 462 | } |
| 463 | if (this.data != null) { |
| 464 | oprot.writeFieldBegin(DATA_FIELD_DESC); |
| 465 | oprot.writeBinary(this.data); |
| 466 | oprot.writeFieldEnd(); |
| 467 | } |
| 468 | oprot.writeFieldStop(); |
| 469 | oprot.writeStructEnd(); |
| 470 | } |
| 471 | |
| 472 | @Override |
| 473 | public String toString() { |
| 474 | StringBuilder sb = new StringBuilder("Packet("); |
| 475 | boolean first = true; |
| 476 | |
| 477 | sb.append("messageType:"); |
| 478 | if (this.messageType == null) { |
| 479 | sb.append("null"); |
| 480 | } else { |
| 481 | sb.append(this.messageType); |
| 482 | } |
| 483 | first = false; |
| 484 | if (!first) sb.append(", "); |
| 485 | sb.append("swPortTuple:"); |
| 486 | if (this.swPortTuple == null) { |
| 487 | sb.append("null"); |
| 488 | } else { |
| 489 | sb.append(this.swPortTuple); |
| 490 | } |
| 491 | first = false; |
| 492 | if (!first) sb.append(", "); |
| 493 | sb.append("data:"); |
| 494 | if (this.data == null) { |
| 495 | sb.append("null"); |
| 496 | } else { |
| 497 | org.apache.thrift.TBaseHelper.toString(this.data, sb); |
| 498 | } |
| 499 | first = false; |
| 500 | sb.append(")"); |
| 501 | return sb.toString(); |
| 502 | } |
| 503 | |
| 504 | public void validate() throws org.apache.thrift.TException { |
| 505 | // check for required fields |
| 506 | } |
| 507 | |
| 508 | private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { |
| 509 | try { |
| 510 | write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); |
| 511 | } catch (org.apache.thrift.TException te) { |
| 512 | throw new java.io.IOException(te); |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { |
| 517 | try { |
| 518 | read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); |
| 519 | } catch (org.apache.thrift.TException te) { |
| 520 | throw new java.io.IOException(te); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | } |
| 525 | |