Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 ashish 1
/**
2
 * Autogenerated by Thrift
3
 *
4
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
 */
6
package in.shop2020.model.v1.order;
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.util.Arrays;
19
import org.slf4j.Logger;
20
import org.slf4j.LoggerFactory;
21
 
22
import org.apache.thrift.*;
23
import org.apache.thrift.meta_data.*;
24
import org.apache.thrift.protocol.*;
25
 
26
public class OrderInfo implements TBase<OrderInfo._Fields>, java.io.Serializable, Cloneable {
27
  private static final TStruct STRUCT_DESC = new TStruct("OrderInfo");
28
 
29
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
30
  private static final TField LINEITEMS_FIELD_DESC = new TField("lineitems", TType.LIST, (short)2);
31
 
32
  private long id;
33
  private List<LineItem> lineitems;
34
 
35
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
36
  public enum _Fields implements TFieldIdEnum {
37
    ID((short)1, "id"),
38
    LINEITEMS((short)2, "lineitems");
39
 
40
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
41
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
42
 
43
    static {
44
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
45
        byId.put((int)field._thriftId, field);
46
        byName.put(field.getFieldName(), field);
47
      }
48
    }
49
 
50
    /**
51
     * Find the _Fields constant that matches fieldId, or null if its not found.
52
     */
53
    public static _Fields findByThriftId(int fieldId) {
54
      return byId.get(fieldId);
55
    }
56
 
57
    /**
58
     * Find the _Fields constant that matches fieldId, throwing an exception
59
     * if it is not found.
60
     */
61
    public static _Fields findByThriftIdOrThrow(int fieldId) {
62
      _Fields fields = findByThriftId(fieldId);
63
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
64
      return fields;
65
    }
66
 
67
    /**
68
     * Find the _Fields constant that matches name, or null if its not found.
69
     */
70
    public static _Fields findByName(String name) {
71
      return byName.get(name);
72
    }
73
 
74
    private final short _thriftId;
75
    private final String _fieldName;
76
 
77
    _Fields(short thriftId, String fieldName) {
78
      _thriftId = thriftId;
79
      _fieldName = fieldName;
80
    }
81
 
82
    public short getThriftFieldId() {
83
      return _thriftId;
84
    }
85
 
86
    public String getFieldName() {
87
      return _fieldName;
88
    }
89
  }
90
 
91
  // isset id assignments
92
  private static final int __ID_ISSET_ID = 0;
93
  private BitSet __isset_bit_vector = new BitSet(1);
94
 
95
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
96
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
97
        new FieldValueMetaData(TType.I64)));
98
    put(_Fields.LINEITEMS, new FieldMetaData("lineitems", TFieldRequirementType.DEFAULT, 
99
        new ListMetaData(TType.LIST, 
100
            new StructMetaData(TType.STRUCT, LineItem.class))));
101
  }});
102
 
103
  static {
104
    FieldMetaData.addStructMetaDataMap(OrderInfo.class, metaDataMap);
105
  }
106
 
107
  public OrderInfo() {
108
  }
109
 
110
  public OrderInfo(
111
    long id,
112
    List<LineItem> lineitems)
113
  {
114
    this();
115
    this.id = id;
116
    setIdIsSet(true);
117
    this.lineitems = lineitems;
118
  }
119
 
120
  /**
121
   * Performs a deep copy on <i>other</i>.
122
   */
123
  public OrderInfo(OrderInfo other) {
124
    __isset_bit_vector.clear();
125
    __isset_bit_vector.or(other.__isset_bit_vector);
126
    this.id = other.id;
127
    if (other.isSetLineitems()) {
128
      List<LineItem> __this__lineitems = new ArrayList<LineItem>();
129
      for (LineItem other_element : other.lineitems) {
130
        __this__lineitems.add(new LineItem(other_element));
131
      }
132
      this.lineitems = __this__lineitems;
133
    }
134
  }
135
 
136
  public OrderInfo deepCopy() {
137
    return new OrderInfo(this);
138
  }
139
 
140
  @Deprecated
141
  public OrderInfo clone() {
142
    return new OrderInfo(this);
143
  }
144
 
145
  public long getId() {
146
    return this.id;
147
  }
148
 
149
  public OrderInfo setId(long id) {
150
    this.id = id;
151
    setIdIsSet(true);
152
    return this;
153
  }
154
 
155
  public void unsetId() {
156
    __isset_bit_vector.clear(__ID_ISSET_ID);
157
  }
158
 
159
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
160
  public boolean isSetId() {
161
    return __isset_bit_vector.get(__ID_ISSET_ID);
162
  }
163
 
164
  public void setIdIsSet(boolean value) {
165
    __isset_bit_vector.set(__ID_ISSET_ID, value);
166
  }
167
 
168
  public int getLineitemsSize() {
169
    return (this.lineitems == null) ? 0 : this.lineitems.size();
170
  }
171
 
172
  public java.util.Iterator<LineItem> getLineitemsIterator() {
173
    return (this.lineitems == null) ? null : this.lineitems.iterator();
174
  }
175
 
176
  public void addToLineitems(LineItem elem) {
177
    if (this.lineitems == null) {
178
      this.lineitems = new ArrayList<LineItem>();
179
    }
180
    this.lineitems.add(elem);
181
  }
182
 
183
  public List<LineItem> getLineitems() {
184
    return this.lineitems;
185
  }
186
 
187
  public OrderInfo setLineitems(List<LineItem> lineitems) {
188
    this.lineitems = lineitems;
189
    return this;
190
  }
191
 
192
  public void unsetLineitems() {
193
    this.lineitems = null;
194
  }
195
 
196
  /** Returns true if field lineitems is set (has been asigned a value) and false otherwise */
197
  public boolean isSetLineitems() {
198
    return this.lineitems != null;
199
  }
200
 
201
  public void setLineitemsIsSet(boolean value) {
202
    if (!value) {
203
      this.lineitems = null;
204
    }
205
  }
206
 
207
  public void setFieldValue(_Fields field, Object value) {
208
    switch (field) {
209
    case ID:
210
      if (value == null) {
211
        unsetId();
212
      } else {
213
        setId((Long)value);
214
      }
215
      break;
216
 
217
    case LINEITEMS:
218
      if (value == null) {
219
        unsetLineitems();
220
      } else {
221
        setLineitems((List<LineItem>)value);
222
      }
223
      break;
224
 
225
    }
226
  }
227
 
228
  public void setFieldValue(int fieldID, Object value) {
229
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
230
  }
231
 
232
  public Object getFieldValue(_Fields field) {
233
    switch (field) {
234
    case ID:
235
      return new Long(getId());
236
 
237
    case LINEITEMS:
238
      return getLineitems();
239
 
240
    }
241
    throw new IllegalStateException();
242
  }
243
 
244
  public Object getFieldValue(int fieldId) {
245
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
246
  }
247
 
248
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
249
  public boolean isSet(_Fields field) {
250
    switch (field) {
251
    case ID:
252
      return isSetId();
253
    case LINEITEMS:
254
      return isSetLineitems();
255
    }
256
    throw new IllegalStateException();
257
  }
258
 
259
  public boolean isSet(int fieldID) {
260
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
261
  }
262
 
263
  @Override
264
  public boolean equals(Object that) {
265
    if (that == null)
266
      return false;
267
    if (that instanceof OrderInfo)
268
      return this.equals((OrderInfo)that);
269
    return false;
270
  }
271
 
272
  public boolean equals(OrderInfo that) {
273
    if (that == null)
274
      return false;
275
 
276
    boolean this_present_id = true;
277
    boolean that_present_id = true;
278
    if (this_present_id || that_present_id) {
279
      if (!(this_present_id && that_present_id))
280
        return false;
281
      if (this.id != that.id)
282
        return false;
283
    }
284
 
285
    boolean this_present_lineitems = true && this.isSetLineitems();
286
    boolean that_present_lineitems = true && that.isSetLineitems();
287
    if (this_present_lineitems || that_present_lineitems) {
288
      if (!(this_present_lineitems && that_present_lineitems))
289
        return false;
290
      if (!this.lineitems.equals(that.lineitems))
291
        return false;
292
    }
293
 
294
    return true;
295
  }
296
 
297
  @Override
298
  public int hashCode() {
299
    return 0;
300
  }
301
 
302
  public void read(TProtocol iprot) throws TException {
303
    TField field;
304
    iprot.readStructBegin();
305
    while (true)
306
    {
307
      field = iprot.readFieldBegin();
308
      if (field.type == TType.STOP) { 
309
        break;
310
      }
311
      _Fields fieldId = _Fields.findByThriftId(field.id);
312
      if (fieldId == null) {
313
        TProtocolUtil.skip(iprot, field.type);
314
      } else {
315
        switch (fieldId) {
316
          case ID:
317
            if (field.type == TType.I64) {
318
              this.id = iprot.readI64();
319
              setIdIsSet(true);
320
            } else { 
321
              TProtocolUtil.skip(iprot, field.type);
322
            }
323
            break;
324
          case LINEITEMS:
325
            if (field.type == TType.LIST) {
326
              {
327
                TList _list5 = iprot.readListBegin();
328
                this.lineitems = new ArrayList<LineItem>(_list5.size);
329
                for (int _i6 = 0; _i6 < _list5.size; ++_i6)
330
                {
331
                  LineItem _elem7;
332
                  _elem7 = new LineItem();
333
                  _elem7.read(iprot);
334
                  this.lineitems.add(_elem7);
335
                }
336
                iprot.readListEnd();
337
              }
338
            } else { 
339
              TProtocolUtil.skip(iprot, field.type);
340
            }
341
            break;
342
        }
343
        iprot.readFieldEnd();
344
      }
345
    }
346
    iprot.readStructEnd();
347
    validate();
348
  }
349
 
350
  public void write(TProtocol oprot) throws TException {
351
    validate();
352
 
353
    oprot.writeStructBegin(STRUCT_DESC);
354
    oprot.writeFieldBegin(ID_FIELD_DESC);
355
    oprot.writeI64(this.id);
356
    oprot.writeFieldEnd();
357
    if (this.lineitems != null) {
358
      oprot.writeFieldBegin(LINEITEMS_FIELD_DESC);
359
      {
360
        oprot.writeListBegin(new TList(TType.STRUCT, this.lineitems.size()));
361
        for (LineItem _iter8 : this.lineitems)
362
        {
363
          _iter8.write(oprot);
364
        }
365
        oprot.writeListEnd();
366
      }
367
      oprot.writeFieldEnd();
368
    }
369
    oprot.writeFieldStop();
370
    oprot.writeStructEnd();
371
  }
372
 
373
  @Override
374
  public String toString() {
375
    StringBuilder sb = new StringBuilder("OrderInfo(");
376
    boolean first = true;
377
 
378
    sb.append("id:");
379
    sb.append(this.id);
380
    first = false;
381
    if (!first) sb.append(", ");
382
    sb.append("lineitems:");
383
    if (this.lineitems == null) {
384
      sb.append("null");
385
    } else {
386
      sb.append(this.lineitems);
387
    }
388
    first = false;
389
    sb.append(")");
390
    return sb.toString();
391
  }
392
 
393
  public void validate() throws TException {
394
    // check for required fields
395
  }
396
 
397
}
398