Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4189 varun.gupt 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 in.shop2020.model.v1.user;
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
public class ItemCouponDiscount implements org.apache.thrift.TBase<ItemCouponDiscount, ItemCouponDiscount._Fields>, java.io.Serializable, Cloneable {
24
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ItemCouponDiscount");
25
 
26
  private static final org.apache.thrift.protocol.TField ITEM_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("itemId", org.apache.thrift.protocol.TType.I64, (short)1);
27
  private static final org.apache.thrift.protocol.TField COUPON_CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("couponCode", org.apache.thrift.protocol.TType.STRING, (short)2);
28
  private static final org.apache.thrift.protocol.TField DISCOUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("discount", org.apache.thrift.protocol.TType.DOUBLE, (short)3);
29
 
30
  private long itemId; // required
31
  private String couponCode; // required
32
  private double discount; // required
33
 
34
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
35
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
36
    ITEM_ID((short)1, "itemId"),
37
    COUPON_CODE((short)2, "couponCode"),
38
    DISCOUNT((short)3, "discount");
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: // ITEM_ID
54
          return ITEM_ID;
55
        case 2: // COUPON_CODE
56
          return COUPON_CODE;
57
        case 3: // DISCOUNT
58
          return DISCOUNT;
59
        default:
60
          return null;
61
      }
62
    }
63
 
64
    /**
65
     * Find the _Fields constant that matches fieldId, throwing an exception
66
     * if it is not found.
67
     */
68
    public static _Fields findByThriftIdOrThrow(int fieldId) {
69
      _Fields fields = findByThriftId(fieldId);
70
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
71
      return fields;
72
    }
73
 
74
    /**
75
     * Find the _Fields constant that matches name, or null if its not found.
76
     */
77
    public static _Fields findByName(String name) {
78
      return byName.get(name);
79
    }
80
 
81
    private final short _thriftId;
82
    private final String _fieldName;
83
 
84
    _Fields(short thriftId, String fieldName) {
85
      _thriftId = thriftId;
86
      _fieldName = fieldName;
87
    }
88
 
89
    public short getThriftFieldId() {
90
      return _thriftId;
91
    }
92
 
93
    public String getFieldName() {
94
      return _fieldName;
95
    }
96
  }
97
 
98
  // isset id assignments
99
  private static final int __ITEMID_ISSET_ID = 0;
100
  private static final int __DISCOUNT_ISSET_ID = 1;
101
  private BitSet __isset_bit_vector = new BitSet(2);
102
 
103
  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
104
  static {
105
    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
106
    tmpMap.put(_Fields.ITEM_ID, new org.apache.thrift.meta_data.FieldMetaData("itemId", org.apache.thrift.TFieldRequirementType.DEFAULT, 
107
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
108
    tmpMap.put(_Fields.COUPON_CODE, new org.apache.thrift.meta_data.FieldMetaData("couponCode", org.apache.thrift.TFieldRequirementType.DEFAULT, 
109
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
110
    tmpMap.put(_Fields.DISCOUNT, new org.apache.thrift.meta_data.FieldMetaData("discount", org.apache.thrift.TFieldRequirementType.DEFAULT, 
111
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
112
    metaDataMap = Collections.unmodifiableMap(tmpMap);
113
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ItemCouponDiscount.class, metaDataMap);
114
  }
115
 
116
  public ItemCouponDiscount() {
117
  }
118
 
119
  public ItemCouponDiscount(
120
    long itemId,
121
    String couponCode,
122
    double discount)
123
  {
124
    this();
125
    this.itemId = itemId;
126
    setItemIdIsSet(true);
127
    this.couponCode = couponCode;
128
    this.discount = discount;
129
    setDiscountIsSet(true);
130
  }
131
 
132
  /**
133
   * Performs a deep copy on <i>other</i>.
134
   */
135
  public ItemCouponDiscount(ItemCouponDiscount other) {
136
    __isset_bit_vector.clear();
137
    __isset_bit_vector.or(other.__isset_bit_vector);
138
    this.itemId = other.itemId;
139
    if (other.isSetCouponCode()) {
140
      this.couponCode = other.couponCode;
141
    }
142
    this.discount = other.discount;
143
  }
144
 
145
  public ItemCouponDiscount deepCopy() {
146
    return new ItemCouponDiscount(this);
147
  }
148
 
149
  @Override
150
  public void clear() {
151
    setItemIdIsSet(false);
152
    this.itemId = 0;
153
    this.couponCode = null;
154
    setDiscountIsSet(false);
155
    this.discount = 0.0;
156
  }
157
 
158
  public long getItemId() {
159
    return this.itemId;
160
  }
161
 
162
  public void setItemId(long itemId) {
163
    this.itemId = itemId;
164
    setItemIdIsSet(true);
165
  }
166
 
167
  public void unsetItemId() {
168
    __isset_bit_vector.clear(__ITEMID_ISSET_ID);
169
  }
170
 
171
  /** Returns true if field itemId is set (has been assigned a value) and false otherwise */
172
  public boolean isSetItemId() {
173
    return __isset_bit_vector.get(__ITEMID_ISSET_ID);
174
  }
175
 
176
  public void setItemIdIsSet(boolean value) {
177
    __isset_bit_vector.set(__ITEMID_ISSET_ID, value);
178
  }
179
 
180
  public String getCouponCode() {
181
    return this.couponCode;
182
  }
183
 
184
  public void setCouponCode(String couponCode) {
185
    this.couponCode = couponCode;
186
  }
187
 
188
  public void unsetCouponCode() {
189
    this.couponCode = null;
190
  }
191
 
192
  /** Returns true if field couponCode is set (has been assigned a value) and false otherwise */
193
  public boolean isSetCouponCode() {
194
    return this.couponCode != null;
195
  }
196
 
197
  public void setCouponCodeIsSet(boolean value) {
198
    if (!value) {
199
      this.couponCode = null;
200
    }
201
  }
202
 
203
  public double getDiscount() {
204
    return this.discount;
205
  }
206
 
207
  public void setDiscount(double discount) {
208
    this.discount = discount;
209
    setDiscountIsSet(true);
210
  }
211
 
212
  public void unsetDiscount() {
213
    __isset_bit_vector.clear(__DISCOUNT_ISSET_ID);
214
  }
215
 
216
  /** Returns true if field discount is set (has been assigned a value) and false otherwise */
217
  public boolean isSetDiscount() {
218
    return __isset_bit_vector.get(__DISCOUNT_ISSET_ID);
219
  }
220
 
221
  public void setDiscountIsSet(boolean value) {
222
    __isset_bit_vector.set(__DISCOUNT_ISSET_ID, value);
223
  }
224
 
225
  public void setFieldValue(_Fields field, Object value) {
226
    switch (field) {
227
    case ITEM_ID:
228
      if (value == null) {
229
        unsetItemId();
230
      } else {
231
        setItemId((Long)value);
232
      }
233
      break;
234
 
235
    case COUPON_CODE:
236
      if (value == null) {
237
        unsetCouponCode();
238
      } else {
239
        setCouponCode((String)value);
240
      }
241
      break;
242
 
243
    case DISCOUNT:
244
      if (value == null) {
245
        unsetDiscount();
246
      } else {
247
        setDiscount((Double)value);
248
      }
249
      break;
250
 
251
    }
252
  }
253
 
254
  public Object getFieldValue(_Fields field) {
255
    switch (field) {
256
    case ITEM_ID:
257
      return Long.valueOf(getItemId());
258
 
259
    case COUPON_CODE:
260
      return getCouponCode();
261
 
262
    case DISCOUNT:
263
      return Double.valueOf(getDiscount());
264
 
265
    }
266
    throw new IllegalStateException();
267
  }
268
 
269
  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
270
  public boolean isSet(_Fields field) {
271
    if (field == null) {
272
      throw new IllegalArgumentException();
273
    }
274
 
275
    switch (field) {
276
    case ITEM_ID:
277
      return isSetItemId();
278
    case COUPON_CODE:
279
      return isSetCouponCode();
280
    case DISCOUNT:
281
      return isSetDiscount();
282
    }
283
    throw new IllegalStateException();
284
  }
285
 
286
  @Override
287
  public boolean equals(Object that) {
288
    if (that == null)
289
      return false;
290
    if (that instanceof ItemCouponDiscount)
291
      return this.equals((ItemCouponDiscount)that);
292
    return false;
293
  }
294
 
295
  public boolean equals(ItemCouponDiscount that) {
296
    if (that == null)
297
      return false;
298
 
299
    boolean this_present_itemId = true;
300
    boolean that_present_itemId = true;
301
    if (this_present_itemId || that_present_itemId) {
302
      if (!(this_present_itemId && that_present_itemId))
303
        return false;
304
      if (this.itemId != that.itemId)
305
        return false;
306
    }
307
 
308
    boolean this_present_couponCode = true && this.isSetCouponCode();
309
    boolean that_present_couponCode = true && that.isSetCouponCode();
310
    if (this_present_couponCode || that_present_couponCode) {
311
      if (!(this_present_couponCode && that_present_couponCode))
312
        return false;
313
      if (!this.couponCode.equals(that.couponCode))
314
        return false;
315
    }
316
 
317
    boolean this_present_discount = true;
318
    boolean that_present_discount = true;
319
    if (this_present_discount || that_present_discount) {
320
      if (!(this_present_discount && that_present_discount))
321
        return false;
322
      if (this.discount != that.discount)
323
        return false;
324
    }
325
 
326
    return true;
327
  }
328
 
329
  @Override
330
  public int hashCode() {
331
    return 0;
332
  }
333
 
334
  public int compareTo(ItemCouponDiscount other) {
335
    if (!getClass().equals(other.getClass())) {
336
      return getClass().getName().compareTo(other.getClass().getName());
337
    }
338
 
339
    int lastComparison = 0;
340
    ItemCouponDiscount typedOther = (ItemCouponDiscount)other;
341
 
342
    lastComparison = Boolean.valueOf(isSetItemId()).compareTo(typedOther.isSetItemId());
343
    if (lastComparison != 0) {
344
      return lastComparison;
345
    }
346
    if (isSetItemId()) {
347
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.itemId, typedOther.itemId);
348
      if (lastComparison != 0) {
349
        return lastComparison;
350
      }
351
    }
352
    lastComparison = Boolean.valueOf(isSetCouponCode()).compareTo(typedOther.isSetCouponCode());
353
    if (lastComparison != 0) {
354
      return lastComparison;
355
    }
356
    if (isSetCouponCode()) {
357
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.couponCode, typedOther.couponCode);
358
      if (lastComparison != 0) {
359
        return lastComparison;
360
      }
361
    }
362
    lastComparison = Boolean.valueOf(isSetDiscount()).compareTo(typedOther.isSetDiscount());
363
    if (lastComparison != 0) {
364
      return lastComparison;
365
    }
366
    if (isSetDiscount()) {
367
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.discount, typedOther.discount);
368
      if (lastComparison != 0) {
369
        return lastComparison;
370
      }
371
    }
372
    return 0;
373
  }
374
 
375
  public _Fields fieldForId(int fieldId) {
376
    return _Fields.findByThriftId(fieldId);
377
  }
378
 
379
  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
380
    org.apache.thrift.protocol.TField field;
381
    iprot.readStructBegin();
382
    while (true)
383
    {
384
      field = iprot.readFieldBegin();
385
      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
386
        break;
387
      }
388
      switch (field.id) {
389
        case 1: // ITEM_ID
390
          if (field.type == org.apache.thrift.protocol.TType.I64) {
391
            this.itemId = iprot.readI64();
392
            setItemIdIsSet(true);
393
          } else { 
394
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
395
          }
396
          break;
397
        case 2: // COUPON_CODE
398
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
399
            this.couponCode = iprot.readString();
400
          } else { 
401
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
402
          }
403
          break;
404
        case 3: // DISCOUNT
405
          if (field.type == org.apache.thrift.protocol.TType.DOUBLE) {
406
            this.discount = iprot.readDouble();
407
            setDiscountIsSet(true);
408
          } else { 
409
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
410
          }
411
          break;
412
        default:
413
          org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
414
      }
415
      iprot.readFieldEnd();
416
    }
417
    iprot.readStructEnd();
418
    validate();
419
  }
420
 
421
  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
422
    validate();
423
 
424
    oprot.writeStructBegin(STRUCT_DESC);
425
    oprot.writeFieldBegin(ITEM_ID_FIELD_DESC);
426
    oprot.writeI64(this.itemId);
427
    oprot.writeFieldEnd();
428
    if (this.couponCode != null) {
429
      oprot.writeFieldBegin(COUPON_CODE_FIELD_DESC);
430
      oprot.writeString(this.couponCode);
431
      oprot.writeFieldEnd();
432
    }
433
    oprot.writeFieldBegin(DISCOUNT_FIELD_DESC);
434
    oprot.writeDouble(this.discount);
435
    oprot.writeFieldEnd();
436
    oprot.writeFieldStop();
437
    oprot.writeStructEnd();
438
  }
439
 
440
  @Override
441
  public String toString() {
442
    StringBuilder sb = new StringBuilder("ItemCouponDiscount(");
443
    boolean first = true;
444
 
445
    sb.append("itemId:");
446
    sb.append(this.itemId);
447
    first = false;
448
    if (!first) sb.append(", ");
449
    sb.append("couponCode:");
450
    if (this.couponCode == null) {
451
      sb.append("null");
452
    } else {
453
      sb.append(this.couponCode);
454
    }
455
    first = false;
456
    if (!first) sb.append(", ");
457
    sb.append("discount:");
458
    sb.append(this.discount);
459
    first = false;
460
    sb.append(")");
461
    return sb.toString();
462
  }
463
 
464
  public void validate() throws org.apache.thrift.TException {
465
    // check for required fields
466
  }
467
 
468
  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
469
    try {
470
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
471
    } catch (org.apache.thrift.TException te) {
472
      throw new java.io.IOException(te);
473
    }
474
  }
475
 
476
  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
477
    try {
478
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
479
      __isset_bit_vector = new BitSet(1);
480
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
481
    } catch (org.apache.thrift.TException te) {
482
      throw new java.io.IOException(te);
483
    }
484
  }
485
 
486
}
487