Subversion Repositories SmartDukaan

Rev

Go to most recent revision | 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 LineItem implements TBase<LineItem._Fields>, java.io.Serializable, Cloneable {
27
  private static final TStruct STRUCT_DESC = new TStruct("LineItem");
28
 
29
  private static final TField ITEM_FIELD_DESC = new TField("item", TType.STRUCT, (short)1);
30
  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)2);
31
  private static final TField ADDED_ON_FIELD_DESC = new TField("addedOn", TType.I64, (short)3);
32
  private static final TField ADDITIONAL_INFO_FIELD_DESC = new TField("additionalInfo", TType.MAP, (short)4);
33
 
34
  private Item item;
35
  private long id;
36
  private long addedOn;
37
  private Map<String,String> additionalInfo;
38
 
39
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
40
  public enum _Fields implements TFieldIdEnum {
41
    ITEM((short)1, "item"),
42
    ID((short)2, "id"),
43
    ADDED_ON((short)3, "addedOn"),
44
    ADDITIONAL_INFO((short)4, "additionalInfo");
45
 
46
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
47
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
48
 
49
    static {
50
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
51
        byId.put((int)field._thriftId, field);
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
      return byId.get(fieldId);
61
    }
62
 
63
    /**
64
     * Find the _Fields constant that matches fieldId, throwing an exception
65
     * if it is not found.
66
     */
67
    public static _Fields findByThriftIdOrThrow(int fieldId) {
68
      _Fields fields = findByThriftId(fieldId);
69
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
70
      return fields;
71
    }
72
 
73
    /**
74
     * Find the _Fields constant that matches name, or null if its not found.
75
     */
76
    public static _Fields findByName(String name) {
77
      return byName.get(name);
78
    }
79
 
80
    private final short _thriftId;
81
    private final String _fieldName;
82
 
83
    _Fields(short thriftId, String fieldName) {
84
      _thriftId = thriftId;
85
      _fieldName = fieldName;
86
    }
87
 
88
    public short getThriftFieldId() {
89
      return _thriftId;
90
    }
91
 
92
    public String getFieldName() {
93
      return _fieldName;
94
    }
95
  }
96
 
97
  // isset id assignments
98
  private static final int __ID_ISSET_ID = 0;
99
  private static final int __ADDEDON_ISSET_ID = 1;
100
  private BitSet __isset_bit_vector = new BitSet(2);
101
 
102
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
103
    put(_Fields.ITEM, new FieldMetaData("item", TFieldRequirementType.DEFAULT, 
104
        new StructMetaData(TType.STRUCT, Item.class)));
105
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
106
        new FieldValueMetaData(TType.I64)));
107
    put(_Fields.ADDED_ON, new FieldMetaData("addedOn", TFieldRequirementType.DEFAULT, 
108
        new FieldValueMetaData(TType.I64)));
109
    put(_Fields.ADDITIONAL_INFO, new FieldMetaData("additionalInfo", TFieldRequirementType.DEFAULT, 
110
        new MapMetaData(TType.MAP, 
111
            new FieldValueMetaData(TType.STRING), 
112
            new FieldValueMetaData(TType.STRING))));
113
  }});
114
 
115
  static {
116
    FieldMetaData.addStructMetaDataMap(LineItem.class, metaDataMap);
117
  }
118
 
119
  public LineItem() {
120
  }
121
 
122
  public LineItem(
123
    Item item,
124
    long id,
125
    long addedOn,
126
    Map<String,String> additionalInfo)
127
  {
128
    this();
129
    this.item = item;
130
    this.id = id;
131
    setIdIsSet(true);
132
    this.addedOn = addedOn;
133
    setAddedOnIsSet(true);
134
    this.additionalInfo = additionalInfo;
135
  }
136
 
137
  /**
138
   * Performs a deep copy on <i>other</i>.
139
   */
140
  public LineItem(LineItem other) {
141
    __isset_bit_vector.clear();
142
    __isset_bit_vector.or(other.__isset_bit_vector);
143
    if (other.isSetItem()) {
144
      this.item = new Item(other.item);
145
    }
146
    this.id = other.id;
147
    this.addedOn = other.addedOn;
148
    if (other.isSetAdditionalInfo()) {
149
      Map<String,String> __this__additionalInfo = new HashMap<String,String>();
150
      for (Map.Entry<String, String> other_element : other.additionalInfo.entrySet()) {
151
 
152
        String other_element_key = other_element.getKey();
153
        String other_element_value = other_element.getValue();
154
 
155
        String __this__additionalInfo_copy_key = other_element_key;
156
 
157
        String __this__additionalInfo_copy_value = other_element_value;
158
 
159
        __this__additionalInfo.put(__this__additionalInfo_copy_key, __this__additionalInfo_copy_value);
160
      }
161
      this.additionalInfo = __this__additionalInfo;
162
    }
163
  }
164
 
165
  public LineItem deepCopy() {
166
    return new LineItem(this);
167
  }
168
 
169
  @Deprecated
170
  public LineItem clone() {
171
    return new LineItem(this);
172
  }
173
 
174
  public Item getItem() {
175
    return this.item;
176
  }
177
 
178
  public LineItem setItem(Item item) {
179
    this.item = item;
180
    return this;
181
  }
182
 
183
  public void unsetItem() {
184
    this.item = null;
185
  }
186
 
187
  /** Returns true if field item is set (has been asigned a value) and false otherwise */
188
  public boolean isSetItem() {
189
    return this.item != null;
190
  }
191
 
192
  public void setItemIsSet(boolean value) {
193
    if (!value) {
194
      this.item = null;
195
    }
196
  }
197
 
198
  public long getId() {
199
    return this.id;
200
  }
201
 
202
  public LineItem setId(long id) {
203
    this.id = id;
204
    setIdIsSet(true);
205
    return this;
206
  }
207
 
208
  public void unsetId() {
209
    __isset_bit_vector.clear(__ID_ISSET_ID);
210
  }
211
 
212
  /** Returns true if field id is set (has been asigned a value) and false otherwise */
213
  public boolean isSetId() {
214
    return __isset_bit_vector.get(__ID_ISSET_ID);
215
  }
216
 
217
  public void setIdIsSet(boolean value) {
218
    __isset_bit_vector.set(__ID_ISSET_ID, value);
219
  }
220
 
221
  public long getAddedOn() {
222
    return this.addedOn;
223
  }
224
 
225
  public LineItem setAddedOn(long addedOn) {
226
    this.addedOn = addedOn;
227
    setAddedOnIsSet(true);
228
    return this;
229
  }
230
 
231
  public void unsetAddedOn() {
232
    __isset_bit_vector.clear(__ADDEDON_ISSET_ID);
233
  }
234
 
235
  /** Returns true if field addedOn is set (has been asigned a value) and false otherwise */
236
  public boolean isSetAddedOn() {
237
    return __isset_bit_vector.get(__ADDEDON_ISSET_ID);
238
  }
239
 
240
  public void setAddedOnIsSet(boolean value) {
241
    __isset_bit_vector.set(__ADDEDON_ISSET_ID, value);
242
  }
243
 
244
  public int getAdditionalInfoSize() {
245
    return (this.additionalInfo == null) ? 0 : this.additionalInfo.size();
246
  }
247
 
248
  public void putToAdditionalInfo(String key, String val) {
249
    if (this.additionalInfo == null) {
250
      this.additionalInfo = new HashMap<String,String>();
251
    }
252
    this.additionalInfo.put(key, val);
253
  }
254
 
255
  public Map<String,String> getAdditionalInfo() {
256
    return this.additionalInfo;
257
  }
258
 
259
  public LineItem setAdditionalInfo(Map<String,String> additionalInfo) {
260
    this.additionalInfo = additionalInfo;
261
    return this;
262
  }
263
 
264
  public void unsetAdditionalInfo() {
265
    this.additionalInfo = null;
266
  }
267
 
268
  /** Returns true if field additionalInfo is set (has been asigned a value) and false otherwise */
269
  public boolean isSetAdditionalInfo() {
270
    return this.additionalInfo != null;
271
  }
272
 
273
  public void setAdditionalInfoIsSet(boolean value) {
274
    if (!value) {
275
      this.additionalInfo = null;
276
    }
277
  }
278
 
279
  public void setFieldValue(_Fields field, Object value) {
280
    switch (field) {
281
    case ITEM:
282
      if (value == null) {
283
        unsetItem();
284
      } else {
285
        setItem((Item)value);
286
      }
287
      break;
288
 
289
    case ID:
290
      if (value == null) {
291
        unsetId();
292
      } else {
293
        setId((Long)value);
294
      }
295
      break;
296
 
297
    case ADDED_ON:
298
      if (value == null) {
299
        unsetAddedOn();
300
      } else {
301
        setAddedOn((Long)value);
302
      }
303
      break;
304
 
305
    case ADDITIONAL_INFO:
306
      if (value == null) {
307
        unsetAdditionalInfo();
308
      } else {
309
        setAdditionalInfo((Map<String,String>)value);
310
      }
311
      break;
312
 
313
    }
314
  }
315
 
316
  public void setFieldValue(int fieldID, Object value) {
317
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
318
  }
319
 
320
  public Object getFieldValue(_Fields field) {
321
    switch (field) {
322
    case ITEM:
323
      return getItem();
324
 
325
    case ID:
326
      return new Long(getId());
327
 
328
    case ADDED_ON:
329
      return new Long(getAddedOn());
330
 
331
    case ADDITIONAL_INFO:
332
      return getAdditionalInfo();
333
 
334
    }
335
    throw new IllegalStateException();
336
  }
337
 
338
  public Object getFieldValue(int fieldId) {
339
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
340
  }
341
 
342
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
343
  public boolean isSet(_Fields field) {
344
    switch (field) {
345
    case ITEM:
346
      return isSetItem();
347
    case ID:
348
      return isSetId();
349
    case ADDED_ON:
350
      return isSetAddedOn();
351
    case ADDITIONAL_INFO:
352
      return isSetAdditionalInfo();
353
    }
354
    throw new IllegalStateException();
355
  }
356
 
357
  public boolean isSet(int fieldID) {
358
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
359
  }
360
 
361
  @Override
362
  public boolean equals(Object that) {
363
    if (that == null)
364
      return false;
365
    if (that instanceof LineItem)
366
      return this.equals((LineItem)that);
367
    return false;
368
  }
369
 
370
  public boolean equals(LineItem that) {
371
    if (that == null)
372
      return false;
373
 
374
    boolean this_present_item = true && this.isSetItem();
375
    boolean that_present_item = true && that.isSetItem();
376
    if (this_present_item || that_present_item) {
377
      if (!(this_present_item && that_present_item))
378
        return false;
379
      if (!this.item.equals(that.item))
380
        return false;
381
    }
382
 
383
    boolean this_present_id = true;
384
    boolean that_present_id = true;
385
    if (this_present_id || that_present_id) {
386
      if (!(this_present_id && that_present_id))
387
        return false;
388
      if (this.id != that.id)
389
        return false;
390
    }
391
 
392
    boolean this_present_addedOn = true;
393
    boolean that_present_addedOn = true;
394
    if (this_present_addedOn || that_present_addedOn) {
395
      if (!(this_present_addedOn && that_present_addedOn))
396
        return false;
397
      if (this.addedOn != that.addedOn)
398
        return false;
399
    }
400
 
401
    boolean this_present_additionalInfo = true && this.isSetAdditionalInfo();
402
    boolean that_present_additionalInfo = true && that.isSetAdditionalInfo();
403
    if (this_present_additionalInfo || that_present_additionalInfo) {
404
      if (!(this_present_additionalInfo && that_present_additionalInfo))
405
        return false;
406
      if (!this.additionalInfo.equals(that.additionalInfo))
407
        return false;
408
    }
409
 
410
    return true;
411
  }
412
 
413
  @Override
414
  public int hashCode() {
415
    return 0;
416
  }
417
 
418
  public void read(TProtocol iprot) throws TException {
419
    TField field;
420
    iprot.readStructBegin();
421
    while (true)
422
    {
423
      field = iprot.readFieldBegin();
424
      if (field.type == TType.STOP) { 
425
        break;
426
      }
427
      _Fields fieldId = _Fields.findByThriftId(field.id);
428
      if (fieldId == null) {
429
        TProtocolUtil.skip(iprot, field.type);
430
      } else {
431
        switch (fieldId) {
432
          case ITEM:
433
            if (field.type == TType.STRUCT) {
434
              this.item = new Item();
435
              this.item.read(iprot);
436
            } else { 
437
              TProtocolUtil.skip(iprot, field.type);
438
            }
439
            break;
440
          case ID:
441
            if (field.type == TType.I64) {
442
              this.id = iprot.readI64();
443
              setIdIsSet(true);
444
            } else { 
445
              TProtocolUtil.skip(iprot, field.type);
446
            }
447
            break;
448
          case ADDED_ON:
449
            if (field.type == TType.I64) {
450
              this.addedOn = iprot.readI64();
451
              setAddedOnIsSet(true);
452
            } else { 
453
              TProtocolUtil.skip(iprot, field.type);
454
            }
455
            break;
456
          case ADDITIONAL_INFO:
457
            if (field.type == TType.MAP) {
458
              {
459
                TMap _map0 = iprot.readMapBegin();
460
                this.additionalInfo = new HashMap<String,String>(2*_map0.size);
461
                for (int _i1 = 0; _i1 < _map0.size; ++_i1)
462
                {
463
                  String _key2;
464
                  String _val3;
465
                  _key2 = iprot.readString();
466
                  _val3 = iprot.readString();
467
                  this.additionalInfo.put(_key2, _val3);
468
                }
469
                iprot.readMapEnd();
470
              }
471
            } else { 
472
              TProtocolUtil.skip(iprot, field.type);
473
            }
474
            break;
475
        }
476
        iprot.readFieldEnd();
477
      }
478
    }
479
    iprot.readStructEnd();
480
    validate();
481
  }
482
 
483
  public void write(TProtocol oprot) throws TException {
484
    validate();
485
 
486
    oprot.writeStructBegin(STRUCT_DESC);
487
    if (this.item != null) {
488
      oprot.writeFieldBegin(ITEM_FIELD_DESC);
489
      this.item.write(oprot);
490
      oprot.writeFieldEnd();
491
    }
492
    oprot.writeFieldBegin(ID_FIELD_DESC);
493
    oprot.writeI64(this.id);
494
    oprot.writeFieldEnd();
495
    oprot.writeFieldBegin(ADDED_ON_FIELD_DESC);
496
    oprot.writeI64(this.addedOn);
497
    oprot.writeFieldEnd();
498
    if (this.additionalInfo != null) {
499
      oprot.writeFieldBegin(ADDITIONAL_INFO_FIELD_DESC);
500
      {
501
        oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, this.additionalInfo.size()));
502
        for (Map.Entry<String, String> _iter4 : this.additionalInfo.entrySet())
503
        {
504
          oprot.writeString(_iter4.getKey());
505
          oprot.writeString(_iter4.getValue());
506
        }
507
        oprot.writeMapEnd();
508
      }
509
      oprot.writeFieldEnd();
510
    }
511
    oprot.writeFieldStop();
512
    oprot.writeStructEnd();
513
  }
514
 
515
  @Override
516
  public String toString() {
517
    StringBuilder sb = new StringBuilder("LineItem(");
518
    boolean first = true;
519
 
520
    sb.append("item:");
521
    if (this.item == null) {
522
      sb.append("null");
523
    } else {
524
      sb.append(this.item);
525
    }
526
    first = false;
527
    if (!first) sb.append(", ");
528
    sb.append("id:");
529
    sb.append(this.id);
530
    first = false;
531
    if (!first) sb.append(", ");
532
    sb.append("addedOn:");
533
    sb.append(this.addedOn);
534
    first = false;
535
    if (!first) sb.append(", ");
536
    sb.append("additionalInfo:");
537
    if (this.additionalInfo == null) {
538
      sb.append("null");
539
    } else {
540
      sb.append(this.additionalInfo);
541
    }
542
    first = false;
543
    sb.append(")");
544
    return sb.toString();
545
  }
546
 
547
  public void validate() throws TException {
548
    // check for required fields
549
  }
550
 
551
}
552