Subversion Repositories SmartDukaan

Rev

Rev 1982 | Rev 3430 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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