77ab80d4ec5dc1f1ade771bc8849459ef4f78fbc
[vpnservice.git] / bgpmanager / bgpmanager-impl / src / main / java / org / opendaylight / bgpmanager / thrift / gen / Routes.java
1 /**
2  * Autogenerated by Thrift Compiler (0.9.1)
3  *
4  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5  *  @generated
6  */
7 package org.opendaylight.bgpmanager.thrift.gen;
8
9 import org.apache.thrift.scheme.IScheme;
10 import org.apache.thrift.scheme.SchemeFactory;
11 import org.apache.thrift.scheme.StandardScheme;
12
13 import org.apache.thrift.scheme.TupleScheme;
14 import org.apache.thrift.protocol.TTupleProtocol;
15 import org.apache.thrift.protocol.TProtocolException;
16 import org.apache.thrift.EncodingUtils;
17 import org.apache.thrift.TException;
18 import org.apache.thrift.async.AsyncMethodCallback;
19 import org.apache.thrift.server.AbstractNonblockingServer.*;
20 import java.util.List;
21 import java.util.ArrayList;
22 import java.util.Map;
23 import java.util.HashMap;
24 import java.util.EnumMap;
25 import java.util.Set;
26 import java.util.HashSet;
27 import java.util.EnumSet;
28 import java.util.Collections;
29 import java.util.BitSet;
30 import java.nio.ByteBuffer;
31 import java.util.Arrays;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
35 public class Routes implements org.apache.thrift.TBase<Routes, Routes._Fields>, java.io.Serializable, Cloneable, Comparable<Routes> {
36   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Routes");
37
38   private static final org.apache.thrift.protocol.TField ERRCODE_FIELD_DESC = new org.apache.thrift.protocol.TField("errcode", org.apache.thrift.protocol.TType.I32, (short)1);
39   private static final org.apache.thrift.protocol.TField UPDATES_FIELD_DESC = new org.apache.thrift.protocol.TField("updates", org.apache.thrift.protocol.TType.LIST, (short)2);
40   private static final org.apache.thrift.protocol.TField MORE_FIELD_DESC = new org.apache.thrift.protocol.TField("more", org.apache.thrift.protocol.TType.I32, (short)4);
41
42   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
43   static {
44     schemes.put(StandardScheme.class, new RoutesStandardSchemeFactory());
45     schemes.put(TupleScheme.class, new RoutesTupleSchemeFactory());
46   }
47
48   public int errcode; // required
49   public List<Update> updates; // optional
50   public int more; // optional
51
52   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
53   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
54     ERRCODE((short)1, "errcode"),
55     UPDATES((short)2, "updates"),
56     MORE((short)4, "more");
57
58     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
59
60     static {
61       for (_Fields field : EnumSet.allOf(_Fields.class)) {
62         byName.put(field.getFieldName(), field);
63       }
64     }
65
66     /**
67      * Find the _Fields constant that matches fieldId, or null if its not found.
68      */
69     public static _Fields findByThriftId(int fieldId) {
70       switch(fieldId) {
71         case 1: // ERRCODE
72           return ERRCODE;
73         case 2: // UPDATES
74           return UPDATES;
75         case 4: // MORE
76           return MORE;
77         default:
78           return null;
79       }
80     }
81
82     /**
83      * Find the _Fields constant that matches fieldId, throwing an exception
84      * if it is not found.
85      */
86     public static _Fields findByThriftIdOrThrow(int fieldId) {
87       _Fields fields = findByThriftId(fieldId);
88       if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
89       return fields;
90     }
91
92     /**
93      * Find the _Fields constant that matches name, or null if its not found.
94      */
95     public static _Fields findByName(String name) {
96       return byName.get(name);
97     }
98
99     private final short _thriftId;
100     private final String _fieldName;
101
102     _Fields(short thriftId, String fieldName) {
103       _thriftId = thriftId;
104       _fieldName = fieldName;
105     }
106
107     public short getThriftFieldId() {
108       return _thriftId;
109     }
110
111     public String getFieldName() {
112       return _fieldName;
113     }
114   }
115
116   // isset id assignments
117   private static final int __ERRCODE_ISSET_ID = 0;
118   private static final int __MORE_ISSET_ID = 1;
119   private byte __isset_bitfield = 0;
120   private _Fields optionals[] = {_Fields.UPDATES,_Fields.MORE};
121   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
122   static {
123     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
124     tmpMap.put(_Fields.ERRCODE, new org.apache.thrift.meta_data.FieldMetaData("errcode", org.apache.thrift.TFieldRequirementType.DEFAULT, 
125         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
126     tmpMap.put(_Fields.UPDATES, new org.apache.thrift.meta_data.FieldMetaData("updates", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
127         new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
128             new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, Update.class))));
129     tmpMap.put(_Fields.MORE, new org.apache.thrift.meta_data.FieldMetaData("more", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
130         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
131     metaDataMap = Collections.unmodifiableMap(tmpMap);
132     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Routes.class, metaDataMap);
133   }
134
135   public Routes() {
136   }
137
138   public Routes(
139     int errcode)
140   {
141     this();
142     this.errcode = errcode;
143     setErrcodeIsSet(true);
144   }
145
146   /**
147    * Performs a deep copy on <i>other</i>.
148    */
149   public Routes(Routes other) {
150     __isset_bitfield = other.__isset_bitfield;
151     this.errcode = other.errcode;
152     if (other.isSetUpdates()) {
153       List<Update> __this__updates = new ArrayList<Update>(other.updates.size());
154       for (Update other_element : other.updates) {
155         __this__updates.add(new Update(other_element));
156       }
157       this.updates = __this__updates;
158     }
159     this.more = other.more;
160   }
161
162   public Routes deepCopy() {
163     return new Routes(this);
164   }
165
166   @Override
167   public void clear() {
168     setErrcodeIsSet(false);
169     this.errcode = 0;
170     this.updates = null;
171     setMoreIsSet(false);
172     this.more = 0;
173   }
174
175   public int getErrcode() {
176     return this.errcode;
177   }
178
179   public Routes setErrcode(int errcode) {
180     this.errcode = errcode;
181     setErrcodeIsSet(true);
182     return this;
183   }
184
185   public void unsetErrcode() {
186     __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ERRCODE_ISSET_ID);
187   }
188
189   /** Returns true if field errcode is set (has been assigned a value) and false otherwise */
190   public boolean isSetErrcode() {
191     return EncodingUtils.testBit(__isset_bitfield, __ERRCODE_ISSET_ID);
192   }
193
194   public void setErrcodeIsSet(boolean value) {
195     __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ERRCODE_ISSET_ID, value);
196   }
197
198   public int getUpdatesSize() {
199     return (this.updates == null) ? 0 : this.updates.size();
200   }
201
202   public java.util.Iterator<Update> getUpdatesIterator() {
203     return (this.updates == null) ? null : this.updates.iterator();
204   }
205
206   public void addToUpdates(Update elem) {
207     if (this.updates == null) {
208       this.updates = new ArrayList<Update>();
209     }
210     this.updates.add(elem);
211   }
212
213   public List<Update> getUpdates() {
214     return this.updates;
215   }
216
217   public Routes setUpdates(List<Update> updates) {
218     this.updates = updates;
219     return this;
220   }
221
222   public void unsetUpdates() {
223     this.updates = null;
224   }
225
226   /** Returns true if field updates is set (has been assigned a value) and false otherwise */
227   public boolean isSetUpdates() {
228     return this.updates != null;
229   }
230
231   public void setUpdatesIsSet(boolean value) {
232     if (!value) {
233       this.updates = null;
234     }
235   }
236
237   public int getMore() {
238     return this.more;
239   }
240
241   public Routes setMore(int more) {
242     this.more = more;
243     setMoreIsSet(true);
244     return this;
245   }
246
247   public void unsetMore() {
248     __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __MORE_ISSET_ID);
249   }
250
251   /** Returns true if field more is set (has been assigned a value) and false otherwise */
252   public boolean isSetMore() {
253     return EncodingUtils.testBit(__isset_bitfield, __MORE_ISSET_ID);
254   }
255
256   public void setMoreIsSet(boolean value) {
257     __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __MORE_ISSET_ID, value);
258   }
259
260   public void setFieldValue(_Fields field, Object value) {
261     switch (field) {
262     case ERRCODE:
263       if (value == null) {
264         unsetErrcode();
265       } else {
266         setErrcode((Integer)value);
267       }
268       break;
269
270     case UPDATES:
271       if (value == null) {
272         unsetUpdates();
273       } else {
274         setUpdates((List<Update>)value);
275       }
276       break;
277
278     case MORE:
279       if (value == null) {
280         unsetMore();
281       } else {
282         setMore((Integer)value);
283       }
284       break;
285
286     }
287   }
288
289   public Object getFieldValue(_Fields field) {
290     switch (field) {
291     case ERRCODE:
292       return Integer.valueOf(getErrcode());
293
294     case UPDATES:
295       return getUpdates();
296
297     case MORE:
298       return Integer.valueOf(getMore());
299
300     }
301     throw new IllegalStateException();
302   }
303
304   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
305   public boolean isSet(_Fields field) {
306     if (field == null) {
307       throw new IllegalArgumentException();
308     }
309
310     switch (field) {
311     case ERRCODE:
312       return isSetErrcode();
313     case UPDATES:
314       return isSetUpdates();
315     case MORE:
316       return isSetMore();
317     }
318     throw new IllegalStateException();
319   }
320
321   @Override
322   public boolean equals(Object that) {
323     if (that == null)
324       return false;
325     if (that instanceof Routes)
326       return this.equals((Routes)that);
327     return false;
328   }
329
330   public boolean equals(Routes that) {
331     if (that == null)
332       return false;
333
334     boolean this_present_errcode = true;
335     boolean that_present_errcode = true;
336     if (this_present_errcode || that_present_errcode) {
337       if (!(this_present_errcode && that_present_errcode))
338         return false;
339       if (this.errcode != that.errcode)
340         return false;
341     }
342
343     boolean this_present_updates = true && this.isSetUpdates();
344     boolean that_present_updates = true && that.isSetUpdates();
345     if (this_present_updates || that_present_updates) {
346       if (!(this_present_updates && that_present_updates))
347         return false;
348       if (!this.updates.equals(that.updates))
349         return false;
350     }
351
352     boolean this_present_more = true && this.isSetMore();
353     boolean that_present_more = true && that.isSetMore();
354     if (this_present_more || that_present_more) {
355       if (!(this_present_more && that_present_more))
356         return false;
357       if (this.more != that.more)
358         return false;
359     }
360
361     return true;
362   }
363
364   @Override
365   public int hashCode() {
366     return 0;
367   }
368
369   @Override
370   public int compareTo(Routes other) {
371     if (!getClass().equals(other.getClass())) {
372       return getClass().getName().compareTo(other.getClass().getName());
373     }
374
375     int lastComparison = 0;
376
377     lastComparison = Boolean.valueOf(isSetErrcode()).compareTo(other.isSetErrcode());
378     if (lastComparison != 0) {
379       return lastComparison;
380     }
381     if (isSetErrcode()) {
382       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.errcode, other.errcode);
383       if (lastComparison != 0) {
384         return lastComparison;
385       }
386     }
387     lastComparison = Boolean.valueOf(isSetUpdates()).compareTo(other.isSetUpdates());
388     if (lastComparison != 0) {
389       return lastComparison;
390     }
391     if (isSetUpdates()) {
392       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.updates, other.updates);
393       if (lastComparison != 0) {
394         return lastComparison;
395       }
396     }
397     lastComparison = Boolean.valueOf(isSetMore()).compareTo(other.isSetMore());
398     if (lastComparison != 0) {
399       return lastComparison;
400     }
401     if (isSetMore()) {
402       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.more, other.more);
403       if (lastComparison != 0) {
404         return lastComparison;
405       }
406     }
407     return 0;
408   }
409
410   public _Fields fieldForId(int fieldId) {
411     return _Fields.findByThriftId(fieldId);
412   }
413
414   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
415     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
416   }
417
418   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
419     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
420   }
421
422   @Override
423   public String toString() {
424     StringBuilder sb = new StringBuilder("Routes(");
425     boolean first = true;
426
427     sb.append("errcode:");
428     sb.append(this.errcode);
429     first = false;
430     if (isSetUpdates()) {
431       if (!first) sb.append(", ");
432       sb.append("updates:");
433       if (this.updates == null) {
434         sb.append("null");
435       } else {
436         sb.append(this.updates);
437       }
438       first = false;
439     }
440     if (isSetMore()) {
441       if (!first) sb.append(", ");
442       sb.append("more:");
443       sb.append(this.more);
444       first = false;
445     }
446     sb.append(")");
447     return sb.toString();
448   }
449
450   public void validate() throws org.apache.thrift.TException {
451     // check for required fields
452     // check for sub-struct validity
453   }
454
455   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
456     try {
457       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
458     } catch (org.apache.thrift.TException te) {
459       throw new java.io.IOException(te);
460     }
461   }
462
463   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
464     try {
465       // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
466       __isset_bitfield = 0;
467       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
468     } catch (org.apache.thrift.TException te) {
469       throw new java.io.IOException(te);
470     }
471   }
472
473   private static class RoutesStandardSchemeFactory implements SchemeFactory {
474     public RoutesStandardScheme getScheme() {
475       return new RoutesStandardScheme();
476     }
477   }
478
479   private static class RoutesStandardScheme extends StandardScheme<Routes> {
480
481     public void read(org.apache.thrift.protocol.TProtocol iprot, Routes struct) throws org.apache.thrift.TException {
482       org.apache.thrift.protocol.TField schemeField;
483       iprot.readStructBegin();
484       while (true)
485       {
486         schemeField = iprot.readFieldBegin();
487         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
488           break;
489         }
490         switch (schemeField.id) {
491           case 1: // ERRCODE
492             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
493               struct.errcode = iprot.readI32();
494               struct.setErrcodeIsSet(true);
495             } else { 
496               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
497             }
498             break;
499           case 2: // UPDATES
500             if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
501               {
502                 org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
503                 struct.updates = new ArrayList<Update>(_list0.size);
504                 for (int _i1 = 0; _i1 < _list0.size; ++_i1)
505                 {
506                   Update _elem2;
507                   _elem2 = new Update();
508                   _elem2.read(iprot);
509                   struct.updates.add(_elem2);
510                 }
511                 iprot.readListEnd();
512               }
513               struct.setUpdatesIsSet(true);
514             } else { 
515               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
516             }
517             break;
518           case 4: // MORE
519             if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
520               struct.more = iprot.readI32();
521               struct.setMoreIsSet(true);
522             } else { 
523               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
524             }
525             break;
526           default:
527             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
528         }
529         iprot.readFieldEnd();
530       }
531       iprot.readStructEnd();
532
533       // check for required fields of primitive type, which can't be checked in the validate method
534       struct.validate();
535     }
536
537     public void write(org.apache.thrift.protocol.TProtocol oprot, Routes struct) throws org.apache.thrift.TException {
538       struct.validate();
539
540       oprot.writeStructBegin(STRUCT_DESC);
541       oprot.writeFieldBegin(ERRCODE_FIELD_DESC);
542       oprot.writeI32(struct.errcode);
543       oprot.writeFieldEnd();
544       if (struct.updates != null) {
545         if (struct.isSetUpdates()) {
546           oprot.writeFieldBegin(UPDATES_FIELD_DESC);
547           {
548             oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.updates.size()));
549             for (Update _iter3 : struct.updates)
550             {
551               _iter3.write(oprot);
552             }
553             oprot.writeListEnd();
554           }
555           oprot.writeFieldEnd();
556         }
557       }
558       if (struct.isSetMore()) {
559         oprot.writeFieldBegin(MORE_FIELD_DESC);
560         oprot.writeI32(struct.more);
561         oprot.writeFieldEnd();
562       }
563       oprot.writeFieldStop();
564       oprot.writeStructEnd();
565     }
566
567   }
568
569   private static class RoutesTupleSchemeFactory implements SchemeFactory {
570     public RoutesTupleScheme getScheme() {
571       return new RoutesTupleScheme();
572     }
573   }
574
575   private static class RoutesTupleScheme extends TupleScheme<Routes> {
576
577     @Override
578     public void write(org.apache.thrift.protocol.TProtocol prot, Routes struct) throws org.apache.thrift.TException {
579       TTupleProtocol oprot = (TTupleProtocol) prot;
580       BitSet optionals = new BitSet();
581       if (struct.isSetErrcode()) {
582         optionals.set(0);
583       }
584       if (struct.isSetUpdates()) {
585         optionals.set(1);
586       }
587       if (struct.isSetMore()) {
588         optionals.set(2);
589       }
590       oprot.writeBitSet(optionals, 3);
591       if (struct.isSetErrcode()) {
592         oprot.writeI32(struct.errcode);
593       }
594       if (struct.isSetUpdates()) {
595         {
596           oprot.writeI32(struct.updates.size());
597           for (Update _iter4 : struct.updates)
598           {
599             _iter4.write(oprot);
600           }
601         }
602       }
603       if (struct.isSetMore()) {
604         oprot.writeI32(struct.more);
605       }
606     }
607
608     @Override
609     public void read(org.apache.thrift.protocol.TProtocol prot, Routes struct) throws org.apache.thrift.TException {
610       TTupleProtocol iprot = (TTupleProtocol) prot;
611       BitSet incoming = iprot.readBitSet(3);
612       if (incoming.get(0)) {
613         struct.errcode = iprot.readI32();
614         struct.setErrcodeIsSet(true);
615       }
616       if (incoming.get(1)) {
617         {
618           org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
619           struct.updates = new ArrayList<Update>(_list5.size);
620           for (int _i6 = 0; _i6 < _list5.size; ++_i6)
621           {
622             Update _elem7;
623             _elem7 = new Update();
624             _elem7.read(iprot);
625             struct.updates.add(_elem7);
626           }
627         }
628         struct.setUpdatesIsSet(true);
629       }
630       if (incoming.get(2)) {
631         struct.more = iprot.readI32();
632         struct.setMoreIsSet(true);
633       }
634     }
635   }
636
637 }
638