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 | /** |
| 24 | * A struct that defines switch port tuple |
| 25 | */ |
| 26 | @SuppressWarnings("all") public class SwitchPortTuple implements org.apache.thrift.TBase<SwitchPortTuple, SwitchPortTuple._Fields>, java.io.Serializable, Cloneable { |
| 27 | private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("SwitchPortTuple"); |
| 28 | |
| 29 | private static final org.apache.thrift.protocol.TField DPID_FIELD_DESC = new org.apache.thrift.protocol.TField("dpid", org.apache.thrift.protocol.TType.I64, (short)1); |
| 30 | private static final org.apache.thrift.protocol.TField PORT_FIELD_DESC = new org.apache.thrift.protocol.TField("port", org.apache.thrift.protocol.TType.I16, (short)2); |
| 31 | |
| 32 | public long dpid; // required |
| 33 | public short port; // required |
| 34 | |
| 35 | /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ |
| 36 | public enum _Fields implements org.apache.thrift.TFieldIdEnum { |
| 37 | DPID((short)1, "dpid"), |
| 38 | PORT((short)2, "port"); |
| 39 | |
| 40 | private static final Map<String, _Fields> byName = new HashMap<String, _Fields>(); |
| 41 | |
| 42 | static { |
| 43 | for (_Fields field : EnumSet.allOf(_Fields.class)) { |
| 44 | byName.put(field.getFieldName(), field); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Find the _Fields constant that matches fieldId, or null if its not found. |
| 50 | */ |
| 51 | public static _Fields findByThriftId(int fieldId) { |
| 52 | switch(fieldId) { |
| 53 | case 1: // DPID |
| 54 | return DPID; |
| 55 | case 2: // PORT |
| 56 | return PORT; |
| 57 | default: |
| 58 | return null; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Find the _Fields constant that matches fieldId, throwing an exception |
| 64 | * if it is not found. |
| 65 | */ |
| 66 | public static _Fields findByThriftIdOrThrow(int fieldId) { |
| 67 | _Fields fields = findByThriftId(fieldId); |
| 68 | if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); |
| 69 | return fields; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Find the _Fields constant that matches name, or null if its not found. |
| 74 | */ |
| 75 | public static _Fields findByName(String name) { |
| 76 | return byName.get(name); |
| 77 | } |
| 78 | |
| 79 | private final short _thriftId; |
| 80 | private final String _fieldName; |
| 81 | |
| 82 | _Fields(short thriftId, String fieldName) { |
| 83 | _thriftId = thriftId; |
| 84 | _fieldName = fieldName; |
| 85 | } |
| 86 | |
| 87 | public short getThriftFieldId() { |
| 88 | return _thriftId; |
| 89 | } |
| 90 | |
| 91 | public String getFieldName() { |
| 92 | return _fieldName; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // isset id assignments |
| 97 | private static final int __DPID_ISSET_ID = 0; |
| 98 | private static final int __PORT_ISSET_ID = 1; |
| 99 | private BitSet __isset_bit_vector = new BitSet(2); |
| 100 | |
| 101 | public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; |
| 102 | static { |
| 103 | Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); |
| 104 | tmpMap.put(_Fields.DPID, new org.apache.thrift.meta_data.FieldMetaData("dpid", org.apache.thrift.TFieldRequirementType.DEFAULT, |
| 105 | new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64))); |
| 106 | tmpMap.put(_Fields.PORT, new org.apache.thrift.meta_data.FieldMetaData("port", org.apache.thrift.TFieldRequirementType.DEFAULT, |
| 107 | new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))); |
| 108 | metaDataMap = Collections.unmodifiableMap(tmpMap); |
| 109 | org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(SwitchPortTuple.class, metaDataMap); |
| 110 | } |
| 111 | |
| 112 | public SwitchPortTuple() { |
| 113 | } |
| 114 | |
| 115 | public SwitchPortTuple( |
| 116 | long dpid, |
| 117 | short port) |
| 118 | { |
| 119 | this(); |
| 120 | this.dpid = dpid; |
| 121 | setDpidIsSet(true); |
| 122 | this.port = port; |
| 123 | setPortIsSet(true); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Performs a deep copy on <i>other</i>. |
| 128 | */ |
| 129 | public SwitchPortTuple(SwitchPortTuple other) { |
| 130 | __isset_bit_vector.clear(); |
| 131 | __isset_bit_vector.or(other.__isset_bit_vector); |
| 132 | this.dpid = other.dpid; |
| 133 | this.port = other.port; |
| 134 | } |
| 135 | |
| 136 | public SwitchPortTuple deepCopy() { |
| 137 | return new SwitchPortTuple(this); |
| 138 | } |
| 139 | |
| 140 | @Override |
| 141 | public void clear() { |
| 142 | setDpidIsSet(false); |
| 143 | this.dpid = 0; |
| 144 | setPortIsSet(false); |
| 145 | this.port = 0; |
| 146 | } |
| 147 | |
| 148 | public long getDpid() { |
| 149 | return this.dpid; |
| 150 | } |
| 151 | |
| 152 | public SwitchPortTuple setDpid(long dpid) { |
| 153 | this.dpid = dpid; |
| 154 | setDpidIsSet(true); |
| 155 | return this; |
| 156 | } |
| 157 | |
| 158 | public void unsetDpid() { |
| 159 | __isset_bit_vector.clear(__DPID_ISSET_ID); |
| 160 | } |
| 161 | |
| 162 | /** Returns true if field dpid is set (has been assigned a value) and false otherwise */ |
| 163 | public boolean isSetDpid() { |
| 164 | return __isset_bit_vector.get(__DPID_ISSET_ID); |
| 165 | } |
| 166 | |
| 167 | public void setDpidIsSet(boolean value) { |
| 168 | __isset_bit_vector.set(__DPID_ISSET_ID, value); |
| 169 | } |
| 170 | |
| 171 | public short getPort() { |
| 172 | return this.port; |
| 173 | } |
| 174 | |
| 175 | public SwitchPortTuple setPort(short port) { |
| 176 | this.port = port; |
| 177 | setPortIsSet(true); |
| 178 | return this; |
| 179 | } |
| 180 | |
| 181 | public void unsetPort() { |
| 182 | __isset_bit_vector.clear(__PORT_ISSET_ID); |
| 183 | } |
| 184 | |
| 185 | /** Returns true if field port is set (has been assigned a value) and false otherwise */ |
| 186 | public boolean isSetPort() { |
| 187 | return __isset_bit_vector.get(__PORT_ISSET_ID); |
| 188 | } |
| 189 | |
| 190 | public void setPortIsSet(boolean value) { |
| 191 | __isset_bit_vector.set(__PORT_ISSET_ID, value); |
| 192 | } |
| 193 | |
| 194 | public void setFieldValue(_Fields field, Object value) { |
| 195 | switch (field) { |
| 196 | case DPID: |
| 197 | if (value == null) { |
| 198 | unsetDpid(); |
| 199 | } else { |
| 200 | setDpid((Long)value); |
| 201 | } |
| 202 | break; |
| 203 | |
| 204 | case PORT: |
| 205 | if (value == null) { |
| 206 | unsetPort(); |
| 207 | } else { |
| 208 | setPort((Short)value); |
| 209 | } |
| 210 | break; |
| 211 | |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | public Object getFieldValue(_Fields field) { |
| 216 | switch (field) { |
| 217 | case DPID: |
| 218 | return Long.valueOf(getDpid()); |
| 219 | |
| 220 | case PORT: |
| 221 | return Short.valueOf(getPort()); |
| 222 | |
| 223 | } |
| 224 | throw new IllegalStateException(); |
| 225 | } |
| 226 | |
| 227 | /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ |
| 228 | public boolean isSet(_Fields field) { |
| 229 | if (field == null) { |
| 230 | throw new IllegalArgumentException(); |
| 231 | } |
| 232 | |
| 233 | switch (field) { |
| 234 | case DPID: |
| 235 | return isSetDpid(); |
| 236 | case PORT: |
| 237 | return isSetPort(); |
| 238 | } |
| 239 | throw new IllegalStateException(); |
| 240 | } |
| 241 | |
| 242 | @Override |
| 243 | public boolean equals(Object that) { |
| 244 | if (that == null) |
| 245 | return false; |
| 246 | if (that instanceof SwitchPortTuple) |
| 247 | return this.equals((SwitchPortTuple)that); |
| 248 | return false; |
| 249 | } |
| 250 | |
| 251 | public boolean equals(SwitchPortTuple that) { |
| 252 | if (that == null) |
| 253 | return false; |
| 254 | |
| 255 | boolean this_present_dpid = true; |
| 256 | boolean that_present_dpid = true; |
| 257 | if (this_present_dpid || that_present_dpid) { |
| 258 | if (!(this_present_dpid && that_present_dpid)) |
| 259 | return false; |
| 260 | if (this.dpid != that.dpid) |
| 261 | return false; |
| 262 | } |
| 263 | |
| 264 | boolean this_present_port = true; |
| 265 | boolean that_present_port = true; |
| 266 | if (this_present_port || that_present_port) { |
| 267 | if (!(this_present_port && that_present_port)) |
| 268 | return false; |
| 269 | if (this.port != that.port) |
| 270 | return false; |
| 271 | } |
| 272 | |
| 273 | return true; |
| 274 | } |
| 275 | |
| 276 | @Override |
| 277 | public int hashCode() { |
| 278 | return 0; |
| 279 | } |
| 280 | |
| 281 | public int compareTo(SwitchPortTuple other) { |
| 282 | if (!getClass().equals(other.getClass())) { |
| 283 | return getClass().getName().compareTo(other.getClass().getName()); |
| 284 | } |
| 285 | |
| 286 | int lastComparison = 0; |
| 287 | SwitchPortTuple typedOther = (SwitchPortTuple)other; |
| 288 | |
| 289 | lastComparison = Boolean.valueOf(isSetDpid()).compareTo(typedOther.isSetDpid()); |
| 290 | if (lastComparison != 0) { |
| 291 | return lastComparison; |
| 292 | } |
| 293 | if (isSetDpid()) { |
| 294 | lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dpid, typedOther.dpid); |
| 295 | if (lastComparison != 0) { |
| 296 | return lastComparison; |
| 297 | } |
| 298 | } |
| 299 | lastComparison = Boolean.valueOf(isSetPort()).compareTo(typedOther.isSetPort()); |
| 300 | if (lastComparison != 0) { |
| 301 | return lastComparison; |
| 302 | } |
| 303 | if (isSetPort()) { |
| 304 | lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.port, typedOther.port); |
| 305 | if (lastComparison != 0) { |
| 306 | return lastComparison; |
| 307 | } |
| 308 | } |
| 309 | return 0; |
| 310 | } |
| 311 | |
| 312 | public _Fields fieldForId(int fieldId) { |
| 313 | return _Fields.findByThriftId(fieldId); |
| 314 | } |
| 315 | |
| 316 | public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { |
| 317 | org.apache.thrift.protocol.TField field; |
| 318 | iprot.readStructBegin(); |
| 319 | while (true) |
| 320 | { |
| 321 | field = iprot.readFieldBegin(); |
| 322 | if (field.type == org.apache.thrift.protocol.TType.STOP) { |
| 323 | break; |
| 324 | } |
| 325 | switch (field.id) { |
| 326 | case 1: // DPID |
| 327 | if (field.type == org.apache.thrift.protocol.TType.I64) { |
| 328 | this.dpid = iprot.readI64(); |
| 329 | setDpidIsSet(true); |
| 330 | } else { |
| 331 | org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); |
| 332 | } |
| 333 | break; |
| 334 | case 2: // PORT |
| 335 | if (field.type == org.apache.thrift.protocol.TType.I16) { |
| 336 | this.port = iprot.readI16(); |
| 337 | setPortIsSet(true); |
| 338 | } else { |
| 339 | org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); |
| 340 | } |
| 341 | break; |
| 342 | default: |
| 343 | org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); |
| 344 | } |
| 345 | iprot.readFieldEnd(); |
| 346 | } |
| 347 | iprot.readStructEnd(); |
| 348 | |
| 349 | // check for required fields of primitive type, which can't be checked in the validate method |
| 350 | validate(); |
| 351 | } |
| 352 | |
| 353 | public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { |
| 354 | validate(); |
| 355 | |
| 356 | oprot.writeStructBegin(STRUCT_DESC); |
| 357 | oprot.writeFieldBegin(DPID_FIELD_DESC); |
| 358 | oprot.writeI64(this.dpid); |
| 359 | oprot.writeFieldEnd(); |
| 360 | oprot.writeFieldBegin(PORT_FIELD_DESC); |
| 361 | oprot.writeI16(this.port); |
| 362 | oprot.writeFieldEnd(); |
| 363 | oprot.writeFieldStop(); |
| 364 | oprot.writeStructEnd(); |
| 365 | } |
| 366 | |
| 367 | @Override |
| 368 | public String toString() { |
| 369 | StringBuilder sb = new StringBuilder("SwitchPortTuple("); |
| 370 | boolean first = true; |
| 371 | |
| 372 | sb.append("dpid:"); |
| 373 | sb.append(this.dpid); |
| 374 | first = false; |
| 375 | if (!first) sb.append(", "); |
| 376 | sb.append("port:"); |
| 377 | sb.append(this.port); |
| 378 | first = false; |
| 379 | sb.append(")"); |
| 380 | return sb.toString(); |
| 381 | } |
| 382 | |
| 383 | public void validate() throws org.apache.thrift.TException { |
| 384 | // check for required fields |
| 385 | } |
| 386 | |
| 387 | private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { |
| 388 | try { |
| 389 | write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); |
| 390 | } catch (org.apache.thrift.TException te) { |
| 391 | throw new java.io.IOException(te); |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { |
| 396 | try { |
| 397 | // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. |
| 398 | __isset_bit_vector = new BitSet(1); |
| 399 | read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); |
| 400 | } catch (org.apache.thrift.TException te) { |
| 401 | throw new java.io.IOException(te); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | } |
| 406 | |