Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
123 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.payments;
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 Payment implements TBase<Payment._Fields>, java.io.Serializable, Cloneable {
27
  private static final TStruct STRUCT_DESC = new TStruct("Payment");
28
 
29
  private static final TField MERCHANT_TX_ID_FIELD_DESC = new TField("merchant_tx_id", TType.I64, (short)1);
30
  private static final TField BANK_TX_ID_FIELD_DESC = new TField("bank_tx_id", TType.I64, (short)2);
31
  private static final TField AMOUNT_FIELD_DESC = new TField("amount", TType.DOUBLE, (short)3);
32
  private static final TField INIT_TIMESTAMP_FIELD_DESC = new TField("init_timestamp", TType.I64, (short)4);
33
  private static final TField BANK_ACK_TIMESTAMP_FIELD_DESC = new TField("bank_ack_timestamp", TType.I64, (short)5);
34
  private static final TField BANK_STATUS_FIELD_DESC = new TField("bank_status", TType.STRING, (short)6);
35
  private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)7);
36
  private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)8);
37
  private static final TField USER_ID_FIELD_DESC = new TField("user_id", TType.I64, (short)9);
38
  private static final TField CART_ID_FIELD_DESC = new TField("cart_id", TType.I64, (short)10);
39
  private static final TField OTHER_INFO_FIELD_DESC = new TField("other_info", TType.MAP, (short)11);
40
  private static final TField GATEWAY_FIELD_DESC = new TField("gateway", TType.I32, (short)12);
41
 
42
  private long merchant_tx_id;
43
  private long bank_tx_id;
44
  private double amount;
45
  private long init_timestamp;
46
  private long bank_ack_timestamp;
47
  private String bank_status;
48
  private PaymentStatus status;
49
  private String message;
50
  private long user_id;
51
  private long cart_id;
52
  private Map<String,String> other_info;
53
  private PaymentGateway gateway;
54
 
55
  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
56
  public enum _Fields implements TFieldIdEnum {
57
    MERCHANT_TX_ID((short)1, "merchant_tx_id"),
58
    BANK_TX_ID((short)2, "bank_tx_id"),
59
    AMOUNT((short)3, "amount"),
60
    INIT_TIMESTAMP((short)4, "init_timestamp"),
61
    BANK_ACK_TIMESTAMP((short)5, "bank_ack_timestamp"),
62
    BANK_STATUS((short)6, "bank_status"),
63
    /**
64
     * 
65
     * @see PaymentStatus
66
     */
67
    STATUS((short)7, "status"),
68
    MESSAGE((short)8, "message"),
69
    USER_ID((short)9, "user_id"),
70
    CART_ID((short)10, "cart_id"),
71
    OTHER_INFO((short)11, "other_info"),
72
    /**
73
     * 
74
     * @see PaymentGateway
75
     */
76
    GATEWAY((short)12, "gateway");
77
 
78
    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
79
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
80
 
81
    static {
82
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
83
        byId.put((int)field._thriftId, field);
84
        byName.put(field.getFieldName(), field);
85
      }
86
    }
87
 
88
    /**
89
     * Find the _Fields constant that matches fieldId, or null if its not found.
90
     */
91
    public static _Fields findByThriftId(int fieldId) {
92
      return byId.get(fieldId);
93
    }
94
 
95
    /**
96
     * Find the _Fields constant that matches fieldId, throwing an exception
97
     * if it is not found.
98
     */
99
    public static _Fields findByThriftIdOrThrow(int fieldId) {
100
      _Fields fields = findByThriftId(fieldId);
101
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
102
      return fields;
103
    }
104
 
105
    /**
106
     * Find the _Fields constant that matches name, or null if its not found.
107
     */
108
    public static _Fields findByName(String name) {
109
      return byName.get(name);
110
    }
111
 
112
    private final short _thriftId;
113
    private final String _fieldName;
114
 
115
    _Fields(short thriftId, String fieldName) {
116
      _thriftId = thriftId;
117
      _fieldName = fieldName;
118
    }
119
 
120
    public short getThriftFieldId() {
121
      return _thriftId;
122
    }
123
 
124
    public String getFieldName() {
125
      return _fieldName;
126
    }
127
  }
128
 
129
  // isset id assignments
130
  private static final int __MERCHANT_TX_ID_ISSET_ID = 0;
131
  private static final int __BANK_TX_ID_ISSET_ID = 1;
132
  private static final int __AMOUNT_ISSET_ID = 2;
133
  private static final int __INIT_TIMESTAMP_ISSET_ID = 3;
134
  private static final int __BANK_ACK_TIMESTAMP_ISSET_ID = 4;
135
  private static final int __USER_ID_ISSET_ID = 5;
136
  private static final int __CART_ID_ISSET_ID = 6;
137
  private BitSet __isset_bit_vector = new BitSet(7);
138
 
139
  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
140
    put(_Fields.MERCHANT_TX_ID, new FieldMetaData("merchant_tx_id", TFieldRequirementType.DEFAULT, 
141
        new FieldValueMetaData(TType.I64)));
142
    put(_Fields.BANK_TX_ID, new FieldMetaData("bank_tx_id", TFieldRequirementType.DEFAULT, 
143
        new FieldValueMetaData(TType.I64)));
144
    put(_Fields.AMOUNT, new FieldMetaData("amount", TFieldRequirementType.DEFAULT, 
145
        new FieldValueMetaData(TType.DOUBLE)));
146
    put(_Fields.INIT_TIMESTAMP, new FieldMetaData("init_timestamp", TFieldRequirementType.DEFAULT, 
147
        new FieldValueMetaData(TType.I64)));
148
    put(_Fields.BANK_ACK_TIMESTAMP, new FieldMetaData("bank_ack_timestamp", TFieldRequirementType.DEFAULT, 
149
        new FieldValueMetaData(TType.I64)));
150
    put(_Fields.BANK_STATUS, new FieldMetaData("bank_status", TFieldRequirementType.DEFAULT, 
151
        new FieldValueMetaData(TType.STRING)));
152
    put(_Fields.STATUS, new FieldMetaData("status", TFieldRequirementType.DEFAULT, 
153
        new EnumMetaData(TType.ENUM, PaymentStatus.class)));
154
    put(_Fields.MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT, 
155
        new FieldValueMetaData(TType.STRING)));
156
    put(_Fields.USER_ID, new FieldMetaData("user_id", TFieldRequirementType.DEFAULT, 
157
        new FieldValueMetaData(TType.I64)));
158
    put(_Fields.CART_ID, new FieldMetaData("cart_id", TFieldRequirementType.DEFAULT, 
159
        new FieldValueMetaData(TType.I64)));
160
    put(_Fields.OTHER_INFO, new FieldMetaData("other_info", TFieldRequirementType.DEFAULT, 
161
        new MapMetaData(TType.MAP, 
162
            new FieldValueMetaData(TType.STRING), 
163
            new FieldValueMetaData(TType.STRING))));
164
    put(_Fields.GATEWAY, new FieldMetaData("gateway", TFieldRequirementType.DEFAULT, 
165
        new EnumMetaData(TType.ENUM, PaymentGateway.class)));
166
  }});
167
 
168
  static {
169
    FieldMetaData.addStructMetaDataMap(Payment.class, metaDataMap);
170
  }
171
 
172
  public Payment() {
173
  }
174
 
175
  public Payment(
176
    long merchant_tx_id,
177
    long bank_tx_id,
178
    double amount,
179
    long init_timestamp,
180
    long bank_ack_timestamp,
181
    String bank_status,
182
    PaymentStatus status,
183
    String message,
184
    long user_id,
185
    long cart_id,
186
    Map<String,String> other_info,
187
    PaymentGateway gateway)
188
  {
189
    this();
190
    this.merchant_tx_id = merchant_tx_id;
191
    setMerchant_tx_idIsSet(true);
192
    this.bank_tx_id = bank_tx_id;
193
    setBank_tx_idIsSet(true);
194
    this.amount = amount;
195
    setAmountIsSet(true);
196
    this.init_timestamp = init_timestamp;
197
    setInit_timestampIsSet(true);
198
    this.bank_ack_timestamp = bank_ack_timestamp;
199
    setBank_ack_timestampIsSet(true);
200
    this.bank_status = bank_status;
201
    this.status = status;
202
    this.message = message;
203
    this.user_id = user_id;
204
    setUser_idIsSet(true);
205
    this.cart_id = cart_id;
206
    setCart_idIsSet(true);
207
    this.other_info = other_info;
208
    this.gateway = gateway;
209
  }
210
 
211
  /**
212
   * Performs a deep copy on <i>other</i>.
213
   */
214
  public Payment(Payment other) {
215
    __isset_bit_vector.clear();
216
    __isset_bit_vector.or(other.__isset_bit_vector);
217
    this.merchant_tx_id = other.merchant_tx_id;
218
    this.bank_tx_id = other.bank_tx_id;
219
    this.amount = other.amount;
220
    this.init_timestamp = other.init_timestamp;
221
    this.bank_ack_timestamp = other.bank_ack_timestamp;
222
    if (other.isSetBank_status()) {
223
      this.bank_status = other.bank_status;
224
    }
225
    if (other.isSetStatus()) {
226
      this.status = other.status;
227
    }
228
    if (other.isSetMessage()) {
229
      this.message = other.message;
230
    }
231
    this.user_id = other.user_id;
232
    this.cart_id = other.cart_id;
233
    if (other.isSetOther_info()) {
234
      Map<String,String> __this__other_info = new HashMap<String,String>();
235
      for (Map.Entry<String, String> other_element : other.other_info.entrySet()) {
236
 
237
        String other_element_key = other_element.getKey();
238
        String other_element_value = other_element.getValue();
239
 
240
        String __this__other_info_copy_key = other_element_key;
241
 
242
        String __this__other_info_copy_value = other_element_value;
243
 
244
        __this__other_info.put(__this__other_info_copy_key, __this__other_info_copy_value);
245
      }
246
      this.other_info = __this__other_info;
247
    }
248
    if (other.isSetGateway()) {
249
      this.gateway = other.gateway;
250
    }
251
  }
252
 
253
  public Payment deepCopy() {
254
    return new Payment(this);
255
  }
256
 
257
  @Deprecated
258
  public Payment clone() {
259
    return new Payment(this);
260
  }
261
 
262
  public long getMerchant_tx_id() {
263
    return this.merchant_tx_id;
264
  }
265
 
266
  public Payment setMerchant_tx_id(long merchant_tx_id) {
267
    this.merchant_tx_id = merchant_tx_id;
268
    setMerchant_tx_idIsSet(true);
269
    return this;
270
  }
271
 
272
  public void unsetMerchant_tx_id() {
273
    __isset_bit_vector.clear(__MERCHANT_TX_ID_ISSET_ID);
274
  }
275
 
276
  /** Returns true if field merchant_tx_id is set (has been asigned a value) and false otherwise */
277
  public boolean isSetMerchant_tx_id() {
278
    return __isset_bit_vector.get(__MERCHANT_TX_ID_ISSET_ID);
279
  }
280
 
281
  public void setMerchant_tx_idIsSet(boolean value) {
282
    __isset_bit_vector.set(__MERCHANT_TX_ID_ISSET_ID, value);
283
  }
284
 
285
  public long getBank_tx_id() {
286
    return this.bank_tx_id;
287
  }
288
 
289
  public Payment setBank_tx_id(long bank_tx_id) {
290
    this.bank_tx_id = bank_tx_id;
291
    setBank_tx_idIsSet(true);
292
    return this;
293
  }
294
 
295
  public void unsetBank_tx_id() {
296
    __isset_bit_vector.clear(__BANK_TX_ID_ISSET_ID);
297
  }
298
 
299
  /** Returns true if field bank_tx_id is set (has been asigned a value) and false otherwise */
300
  public boolean isSetBank_tx_id() {
301
    return __isset_bit_vector.get(__BANK_TX_ID_ISSET_ID);
302
  }
303
 
304
  public void setBank_tx_idIsSet(boolean value) {
305
    __isset_bit_vector.set(__BANK_TX_ID_ISSET_ID, value);
306
  }
307
 
308
  public double getAmount() {
309
    return this.amount;
310
  }
311
 
312
  public Payment setAmount(double amount) {
313
    this.amount = amount;
314
    setAmountIsSet(true);
315
    return this;
316
  }
317
 
318
  public void unsetAmount() {
319
    __isset_bit_vector.clear(__AMOUNT_ISSET_ID);
320
  }
321
 
322
  /** Returns true if field amount is set (has been asigned a value) and false otherwise */
323
  public boolean isSetAmount() {
324
    return __isset_bit_vector.get(__AMOUNT_ISSET_ID);
325
  }
326
 
327
  public void setAmountIsSet(boolean value) {
328
    __isset_bit_vector.set(__AMOUNT_ISSET_ID, value);
329
  }
330
 
331
  public long getInit_timestamp() {
332
    return this.init_timestamp;
333
  }
334
 
335
  public Payment setInit_timestamp(long init_timestamp) {
336
    this.init_timestamp = init_timestamp;
337
    setInit_timestampIsSet(true);
338
    return this;
339
  }
340
 
341
  public void unsetInit_timestamp() {
342
    __isset_bit_vector.clear(__INIT_TIMESTAMP_ISSET_ID);
343
  }
344
 
345
  /** Returns true if field init_timestamp is set (has been asigned a value) and false otherwise */
346
  public boolean isSetInit_timestamp() {
347
    return __isset_bit_vector.get(__INIT_TIMESTAMP_ISSET_ID);
348
  }
349
 
350
  public void setInit_timestampIsSet(boolean value) {
351
    __isset_bit_vector.set(__INIT_TIMESTAMP_ISSET_ID, value);
352
  }
353
 
354
  public long getBank_ack_timestamp() {
355
    return this.bank_ack_timestamp;
356
  }
357
 
358
  public Payment setBank_ack_timestamp(long bank_ack_timestamp) {
359
    this.bank_ack_timestamp = bank_ack_timestamp;
360
    setBank_ack_timestampIsSet(true);
361
    return this;
362
  }
363
 
364
  public void unsetBank_ack_timestamp() {
365
    __isset_bit_vector.clear(__BANK_ACK_TIMESTAMP_ISSET_ID);
366
  }
367
 
368
  /** Returns true if field bank_ack_timestamp is set (has been asigned a value) and false otherwise */
369
  public boolean isSetBank_ack_timestamp() {
370
    return __isset_bit_vector.get(__BANK_ACK_TIMESTAMP_ISSET_ID);
371
  }
372
 
373
  public void setBank_ack_timestampIsSet(boolean value) {
374
    __isset_bit_vector.set(__BANK_ACK_TIMESTAMP_ISSET_ID, value);
375
  }
376
 
377
  public String getBank_status() {
378
    return this.bank_status;
379
  }
380
 
381
  public Payment setBank_status(String bank_status) {
382
    this.bank_status = bank_status;
383
    return this;
384
  }
385
 
386
  public void unsetBank_status() {
387
    this.bank_status = null;
388
  }
389
 
390
  /** Returns true if field bank_status is set (has been asigned a value) and false otherwise */
391
  public boolean isSetBank_status() {
392
    return this.bank_status != null;
393
  }
394
 
395
  public void setBank_statusIsSet(boolean value) {
396
    if (!value) {
397
      this.bank_status = null;
398
    }
399
  }
400
 
401
  /**
402
   * 
403
   * @see PaymentStatus
404
   */
405
  public PaymentStatus getStatus() {
406
    return this.status;
407
  }
408
 
409
  /**
410
   * 
411
   * @see PaymentStatus
412
   */
413
  public Payment setStatus(PaymentStatus status) {
414
    this.status = status;
415
    return this;
416
  }
417
 
418
  public void unsetStatus() {
419
    this.status = null;
420
  }
421
 
422
  /** Returns true if field status is set (has been asigned a value) and false otherwise */
423
  public boolean isSetStatus() {
424
    return this.status != null;
425
  }
426
 
427
  public void setStatusIsSet(boolean value) {
428
    if (!value) {
429
      this.status = null;
430
    }
431
  }
432
 
433
  public String getMessage() {
434
    return this.message;
435
  }
436
 
437
  public Payment setMessage(String message) {
438
    this.message = message;
439
    return this;
440
  }
441
 
442
  public void unsetMessage() {
443
    this.message = null;
444
  }
445
 
446
  /** Returns true if field message is set (has been asigned a value) and false otherwise */
447
  public boolean isSetMessage() {
448
    return this.message != null;
449
  }
450
 
451
  public void setMessageIsSet(boolean value) {
452
    if (!value) {
453
      this.message = null;
454
    }
455
  }
456
 
457
  public long getUser_id() {
458
    return this.user_id;
459
  }
460
 
461
  public Payment setUser_id(long user_id) {
462
    this.user_id = user_id;
463
    setUser_idIsSet(true);
464
    return this;
465
  }
466
 
467
  public void unsetUser_id() {
468
    __isset_bit_vector.clear(__USER_ID_ISSET_ID);
469
  }
470
 
471
  /** Returns true if field user_id is set (has been asigned a value) and false otherwise */
472
  public boolean isSetUser_id() {
473
    return __isset_bit_vector.get(__USER_ID_ISSET_ID);
474
  }
475
 
476
  public void setUser_idIsSet(boolean value) {
477
    __isset_bit_vector.set(__USER_ID_ISSET_ID, value);
478
  }
479
 
480
  public long getCart_id() {
481
    return this.cart_id;
482
  }
483
 
484
  public Payment setCart_id(long cart_id) {
485
    this.cart_id = cart_id;
486
    setCart_idIsSet(true);
487
    return this;
488
  }
489
 
490
  public void unsetCart_id() {
491
    __isset_bit_vector.clear(__CART_ID_ISSET_ID);
492
  }
493
 
494
  /** Returns true if field cart_id is set (has been asigned a value) and false otherwise */
495
  public boolean isSetCart_id() {
496
    return __isset_bit_vector.get(__CART_ID_ISSET_ID);
497
  }
498
 
499
  public void setCart_idIsSet(boolean value) {
500
    __isset_bit_vector.set(__CART_ID_ISSET_ID, value);
501
  }
502
 
503
  public int getOther_infoSize() {
504
    return (this.other_info == null) ? 0 : this.other_info.size();
505
  }
506
 
507
  public void putToOther_info(String key, String val) {
508
    if (this.other_info == null) {
509
      this.other_info = new HashMap<String,String>();
510
    }
511
    this.other_info.put(key, val);
512
  }
513
 
514
  public Map<String,String> getOther_info() {
515
    return this.other_info;
516
  }
517
 
518
  public Payment setOther_info(Map<String,String> other_info) {
519
    this.other_info = other_info;
520
    return this;
521
  }
522
 
523
  public void unsetOther_info() {
524
    this.other_info = null;
525
  }
526
 
527
  /** Returns true if field other_info is set (has been asigned a value) and false otherwise */
528
  public boolean isSetOther_info() {
529
    return this.other_info != null;
530
  }
531
 
532
  public void setOther_infoIsSet(boolean value) {
533
    if (!value) {
534
      this.other_info = null;
535
    }
536
  }
537
 
538
  /**
539
   * 
540
   * @see PaymentGateway
541
   */
542
  public PaymentGateway getGateway() {
543
    return this.gateway;
544
  }
545
 
546
  /**
547
   * 
548
   * @see PaymentGateway
549
   */
550
  public Payment setGateway(PaymentGateway gateway) {
551
    this.gateway = gateway;
552
    return this;
553
  }
554
 
555
  public void unsetGateway() {
556
    this.gateway = null;
557
  }
558
 
559
  /** Returns true if field gateway is set (has been asigned a value) and false otherwise */
560
  public boolean isSetGateway() {
561
    return this.gateway != null;
562
  }
563
 
564
  public void setGatewayIsSet(boolean value) {
565
    if (!value) {
566
      this.gateway = null;
567
    }
568
  }
569
 
570
  public void setFieldValue(_Fields field, Object value) {
571
    switch (field) {
572
    case MERCHANT_TX_ID:
573
      if (value == null) {
574
        unsetMerchant_tx_id();
575
      } else {
576
        setMerchant_tx_id((Long)value);
577
      }
578
      break;
579
 
580
    case BANK_TX_ID:
581
      if (value == null) {
582
        unsetBank_tx_id();
583
      } else {
584
        setBank_tx_id((Long)value);
585
      }
586
      break;
587
 
588
    case AMOUNT:
589
      if (value == null) {
590
        unsetAmount();
591
      } else {
592
        setAmount((Double)value);
593
      }
594
      break;
595
 
596
    case INIT_TIMESTAMP:
597
      if (value == null) {
598
        unsetInit_timestamp();
599
      } else {
600
        setInit_timestamp((Long)value);
601
      }
602
      break;
603
 
604
    case BANK_ACK_TIMESTAMP:
605
      if (value == null) {
606
        unsetBank_ack_timestamp();
607
      } else {
608
        setBank_ack_timestamp((Long)value);
609
      }
610
      break;
611
 
612
    case BANK_STATUS:
613
      if (value == null) {
614
        unsetBank_status();
615
      } else {
616
        setBank_status((String)value);
617
      }
618
      break;
619
 
620
    case STATUS:
621
      if (value == null) {
622
        unsetStatus();
623
      } else {
624
        setStatus((PaymentStatus)value);
625
      }
626
      break;
627
 
628
    case MESSAGE:
629
      if (value == null) {
630
        unsetMessage();
631
      } else {
632
        setMessage((String)value);
633
      }
634
      break;
635
 
636
    case USER_ID:
637
      if (value == null) {
638
        unsetUser_id();
639
      } else {
640
        setUser_id((Long)value);
641
      }
642
      break;
643
 
644
    case CART_ID:
645
      if (value == null) {
646
        unsetCart_id();
647
      } else {
648
        setCart_id((Long)value);
649
      }
650
      break;
651
 
652
    case OTHER_INFO:
653
      if (value == null) {
654
        unsetOther_info();
655
      } else {
656
        setOther_info((Map<String,String>)value);
657
      }
658
      break;
659
 
660
    case GATEWAY:
661
      if (value == null) {
662
        unsetGateway();
663
      } else {
664
        setGateway((PaymentGateway)value);
665
      }
666
      break;
667
 
668
    }
669
  }
670
 
671
  public void setFieldValue(int fieldID, Object value) {
672
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
673
  }
674
 
675
  public Object getFieldValue(_Fields field) {
676
    switch (field) {
677
    case MERCHANT_TX_ID:
678
      return new Long(getMerchant_tx_id());
679
 
680
    case BANK_TX_ID:
681
      return new Long(getBank_tx_id());
682
 
683
    case AMOUNT:
684
      return new Double(getAmount());
685
 
686
    case INIT_TIMESTAMP:
687
      return new Long(getInit_timestamp());
688
 
689
    case BANK_ACK_TIMESTAMP:
690
      return new Long(getBank_ack_timestamp());
691
 
692
    case BANK_STATUS:
693
      return getBank_status();
694
 
695
    case STATUS:
696
      return getStatus();
697
 
698
    case MESSAGE:
699
      return getMessage();
700
 
701
    case USER_ID:
702
      return new Long(getUser_id());
703
 
704
    case CART_ID:
705
      return new Long(getCart_id());
706
 
707
    case OTHER_INFO:
708
      return getOther_info();
709
 
710
    case GATEWAY:
711
      return getGateway();
712
 
713
    }
714
    throw new IllegalStateException();
715
  }
716
 
717
  public Object getFieldValue(int fieldId) {
718
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
719
  }
720
 
721
  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
722
  public boolean isSet(_Fields field) {
723
    switch (field) {
724
    case MERCHANT_TX_ID:
725
      return isSetMerchant_tx_id();
726
    case BANK_TX_ID:
727
      return isSetBank_tx_id();
728
    case AMOUNT:
729
      return isSetAmount();
730
    case INIT_TIMESTAMP:
731
      return isSetInit_timestamp();
732
    case BANK_ACK_TIMESTAMP:
733
      return isSetBank_ack_timestamp();
734
    case BANK_STATUS:
735
      return isSetBank_status();
736
    case STATUS:
737
      return isSetStatus();
738
    case MESSAGE:
739
      return isSetMessage();
740
    case USER_ID:
741
      return isSetUser_id();
742
    case CART_ID:
743
      return isSetCart_id();
744
    case OTHER_INFO:
745
      return isSetOther_info();
746
    case GATEWAY:
747
      return isSetGateway();
748
    }
749
    throw new IllegalStateException();
750
  }
751
 
752
  public boolean isSet(int fieldID) {
753
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
754
  }
755
 
756
  @Override
757
  public boolean equals(Object that) {
758
    if (that == null)
759
      return false;
760
    if (that instanceof Payment)
761
      return this.equals((Payment)that);
762
    return false;
763
  }
764
 
765
  public boolean equals(Payment that) {
766
    if (that == null)
767
      return false;
768
 
769
    boolean this_present_merchant_tx_id = true;
770
    boolean that_present_merchant_tx_id = true;
771
    if (this_present_merchant_tx_id || that_present_merchant_tx_id) {
772
      if (!(this_present_merchant_tx_id && that_present_merchant_tx_id))
773
        return false;
774
      if (this.merchant_tx_id != that.merchant_tx_id)
775
        return false;
776
    }
777
 
778
    boolean this_present_bank_tx_id = true;
779
    boolean that_present_bank_tx_id = true;
780
    if (this_present_bank_tx_id || that_present_bank_tx_id) {
781
      if (!(this_present_bank_tx_id && that_present_bank_tx_id))
782
        return false;
783
      if (this.bank_tx_id != that.bank_tx_id)
784
        return false;
785
    }
786
 
787
    boolean this_present_amount = true;
788
    boolean that_present_amount = true;
789
    if (this_present_amount || that_present_amount) {
790
      if (!(this_present_amount && that_present_amount))
791
        return false;
792
      if (this.amount != that.amount)
793
        return false;
794
    }
795
 
796
    boolean this_present_init_timestamp = true;
797
    boolean that_present_init_timestamp = true;
798
    if (this_present_init_timestamp || that_present_init_timestamp) {
799
      if (!(this_present_init_timestamp && that_present_init_timestamp))
800
        return false;
801
      if (this.init_timestamp != that.init_timestamp)
802
        return false;
803
    }
804
 
805
    boolean this_present_bank_ack_timestamp = true;
806
    boolean that_present_bank_ack_timestamp = true;
807
    if (this_present_bank_ack_timestamp || that_present_bank_ack_timestamp) {
808
      if (!(this_present_bank_ack_timestamp && that_present_bank_ack_timestamp))
809
        return false;
810
      if (this.bank_ack_timestamp != that.bank_ack_timestamp)
811
        return false;
812
    }
813
 
814
    boolean this_present_bank_status = true && this.isSetBank_status();
815
    boolean that_present_bank_status = true && that.isSetBank_status();
816
    if (this_present_bank_status || that_present_bank_status) {
817
      if (!(this_present_bank_status && that_present_bank_status))
818
        return false;
819
      if (!this.bank_status.equals(that.bank_status))
820
        return false;
821
    }
822
 
823
    boolean this_present_status = true && this.isSetStatus();
824
    boolean that_present_status = true && that.isSetStatus();
825
    if (this_present_status || that_present_status) {
826
      if (!(this_present_status && that_present_status))
827
        return false;
828
      if (!this.status.equals(that.status))
829
        return false;
830
    }
831
 
832
    boolean this_present_message = true && this.isSetMessage();
833
    boolean that_present_message = true && that.isSetMessage();
834
    if (this_present_message || that_present_message) {
835
      if (!(this_present_message && that_present_message))
836
        return false;
837
      if (!this.message.equals(that.message))
838
        return false;
839
    }
840
 
841
    boolean this_present_user_id = true;
842
    boolean that_present_user_id = true;
843
    if (this_present_user_id || that_present_user_id) {
844
      if (!(this_present_user_id && that_present_user_id))
845
        return false;
846
      if (this.user_id != that.user_id)
847
        return false;
848
    }
849
 
850
    boolean this_present_cart_id = true;
851
    boolean that_present_cart_id = true;
852
    if (this_present_cart_id || that_present_cart_id) {
853
      if (!(this_present_cart_id && that_present_cart_id))
854
        return false;
855
      if (this.cart_id != that.cart_id)
856
        return false;
857
    }
858
 
859
    boolean this_present_other_info = true && this.isSetOther_info();
860
    boolean that_present_other_info = true && that.isSetOther_info();
861
    if (this_present_other_info || that_present_other_info) {
862
      if (!(this_present_other_info && that_present_other_info))
863
        return false;
864
      if (!this.other_info.equals(that.other_info))
865
        return false;
866
    }
867
 
868
    boolean this_present_gateway = true && this.isSetGateway();
869
    boolean that_present_gateway = true && that.isSetGateway();
870
    if (this_present_gateway || that_present_gateway) {
871
      if (!(this_present_gateway && that_present_gateway))
872
        return false;
873
      if (!this.gateway.equals(that.gateway))
874
        return false;
875
    }
876
 
877
    return true;
878
  }
879
 
880
  @Override
881
  public int hashCode() {
882
    return 0;
883
  }
884
 
885
  public void read(TProtocol iprot) throws TException {
886
    TField field;
887
    iprot.readStructBegin();
888
    while (true)
889
    {
890
      field = iprot.readFieldBegin();
891
      if (field.type == TType.STOP) { 
892
        break;
893
      }
894
      _Fields fieldId = _Fields.findByThriftId(field.id);
895
      if (fieldId == null) {
896
        TProtocolUtil.skip(iprot, field.type);
897
      } else {
898
        switch (fieldId) {
899
          case MERCHANT_TX_ID:
900
            if (field.type == TType.I64) {
901
              this.merchant_tx_id = iprot.readI64();
902
              setMerchant_tx_idIsSet(true);
903
            } else { 
904
              TProtocolUtil.skip(iprot, field.type);
905
            }
906
            break;
907
          case BANK_TX_ID:
908
            if (field.type == TType.I64) {
909
              this.bank_tx_id = iprot.readI64();
910
              setBank_tx_idIsSet(true);
911
            } else { 
912
              TProtocolUtil.skip(iprot, field.type);
913
            }
914
            break;
915
          case AMOUNT:
916
            if (field.type == TType.DOUBLE) {
917
              this.amount = iprot.readDouble();
918
              setAmountIsSet(true);
919
            } else { 
920
              TProtocolUtil.skip(iprot, field.type);
921
            }
922
            break;
923
          case INIT_TIMESTAMP:
924
            if (field.type == TType.I64) {
925
              this.init_timestamp = iprot.readI64();
926
              setInit_timestampIsSet(true);
927
            } else { 
928
              TProtocolUtil.skip(iprot, field.type);
929
            }
930
            break;
931
          case BANK_ACK_TIMESTAMP:
932
            if (field.type == TType.I64) {
933
              this.bank_ack_timestamp = iprot.readI64();
934
              setBank_ack_timestampIsSet(true);
935
            } else { 
936
              TProtocolUtil.skip(iprot, field.type);
937
            }
938
            break;
939
          case BANK_STATUS:
940
            if (field.type == TType.STRING) {
941
              this.bank_status = iprot.readString();
942
            } else { 
943
              TProtocolUtil.skip(iprot, field.type);
944
            }
945
            break;
946
          case STATUS:
947
            if (field.type == TType.I32) {
948
              this.status = PaymentStatus.findByValue(iprot.readI32());
949
            } else { 
950
              TProtocolUtil.skip(iprot, field.type);
951
            }
952
            break;
953
          case MESSAGE:
954
            if (field.type == TType.STRING) {
955
              this.message = iprot.readString();
956
            } else { 
957
              TProtocolUtil.skip(iprot, field.type);
958
            }
959
            break;
960
          case USER_ID:
961
            if (field.type == TType.I64) {
962
              this.user_id = iprot.readI64();
963
              setUser_idIsSet(true);
964
            } else { 
965
              TProtocolUtil.skip(iprot, field.type);
966
            }
967
            break;
968
          case CART_ID:
969
            if (field.type == TType.I64) {
970
              this.cart_id = iprot.readI64();
971
              setCart_idIsSet(true);
972
            } else { 
973
              TProtocolUtil.skip(iprot, field.type);
974
            }
975
            break;
976
          case OTHER_INFO:
977
            if (field.type == TType.MAP) {
978
              {
979
                TMap _map0 = iprot.readMapBegin();
980
                this.other_info = new HashMap<String,String>(2*_map0.size);
981
                for (int _i1 = 0; _i1 < _map0.size; ++_i1)
982
                {
983
                  String _key2;
984
                  String _val3;
985
                  _key2 = iprot.readString();
986
                  _val3 = iprot.readString();
987
                  this.other_info.put(_key2, _val3);
988
                }
989
                iprot.readMapEnd();
990
              }
991
            } else { 
992
              TProtocolUtil.skip(iprot, field.type);
993
            }
994
            break;
995
          case GATEWAY:
996
            if (field.type == TType.I32) {
997
              this.gateway = PaymentGateway.findByValue(iprot.readI32());
998
            } else { 
999
              TProtocolUtil.skip(iprot, field.type);
1000
            }
1001
            break;
1002
        }
1003
        iprot.readFieldEnd();
1004
      }
1005
    }
1006
    iprot.readStructEnd();
1007
    validate();
1008
  }
1009
 
1010
  public void write(TProtocol oprot) throws TException {
1011
    validate();
1012
 
1013
    oprot.writeStructBegin(STRUCT_DESC);
1014
    oprot.writeFieldBegin(MERCHANT_TX_ID_FIELD_DESC);
1015
    oprot.writeI64(this.merchant_tx_id);
1016
    oprot.writeFieldEnd();
1017
    oprot.writeFieldBegin(BANK_TX_ID_FIELD_DESC);
1018
    oprot.writeI64(this.bank_tx_id);
1019
    oprot.writeFieldEnd();
1020
    oprot.writeFieldBegin(AMOUNT_FIELD_DESC);
1021
    oprot.writeDouble(this.amount);
1022
    oprot.writeFieldEnd();
1023
    oprot.writeFieldBegin(INIT_TIMESTAMP_FIELD_DESC);
1024
    oprot.writeI64(this.init_timestamp);
1025
    oprot.writeFieldEnd();
1026
    oprot.writeFieldBegin(BANK_ACK_TIMESTAMP_FIELD_DESC);
1027
    oprot.writeI64(this.bank_ack_timestamp);
1028
    oprot.writeFieldEnd();
1029
    if (this.bank_status != null) {
1030
      oprot.writeFieldBegin(BANK_STATUS_FIELD_DESC);
1031
      oprot.writeString(this.bank_status);
1032
      oprot.writeFieldEnd();
1033
    }
1034
    if (this.status != null) {
1035
      oprot.writeFieldBegin(STATUS_FIELD_DESC);
1036
      oprot.writeI32(this.status.getValue());
1037
      oprot.writeFieldEnd();
1038
    }
1039
    if (this.message != null) {
1040
      oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
1041
      oprot.writeString(this.message);
1042
      oprot.writeFieldEnd();
1043
    }
1044
    oprot.writeFieldBegin(USER_ID_FIELD_DESC);
1045
    oprot.writeI64(this.user_id);
1046
    oprot.writeFieldEnd();
1047
    oprot.writeFieldBegin(CART_ID_FIELD_DESC);
1048
    oprot.writeI64(this.cart_id);
1049
    oprot.writeFieldEnd();
1050
    if (this.other_info != null) {
1051
      oprot.writeFieldBegin(OTHER_INFO_FIELD_DESC);
1052
      {
1053
        oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, this.other_info.size()));
1054
        for (Map.Entry<String, String> _iter4 : this.other_info.entrySet())
1055
        {
1056
          oprot.writeString(_iter4.getKey());
1057
          oprot.writeString(_iter4.getValue());
1058
        }
1059
        oprot.writeMapEnd();
1060
      }
1061
      oprot.writeFieldEnd();
1062
    }
1063
    if (this.gateway != null) {
1064
      oprot.writeFieldBegin(GATEWAY_FIELD_DESC);
1065
      oprot.writeI32(this.gateway.getValue());
1066
      oprot.writeFieldEnd();
1067
    }
1068
    oprot.writeFieldStop();
1069
    oprot.writeStructEnd();
1070
  }
1071
 
1072
  @Override
1073
  public String toString() {
1074
    StringBuilder sb = new StringBuilder("Payment(");
1075
    boolean first = true;
1076
 
1077
    sb.append("merchant_tx_id:");
1078
    sb.append(this.merchant_tx_id);
1079
    first = false;
1080
    if (!first) sb.append(", ");
1081
    sb.append("bank_tx_id:");
1082
    sb.append(this.bank_tx_id);
1083
    first = false;
1084
    if (!first) sb.append(", ");
1085
    sb.append("amount:");
1086
    sb.append(this.amount);
1087
    first = false;
1088
    if (!first) sb.append(", ");
1089
    sb.append("init_timestamp:");
1090
    sb.append(this.init_timestamp);
1091
    first = false;
1092
    if (!first) sb.append(", ");
1093
    sb.append("bank_ack_timestamp:");
1094
    sb.append(this.bank_ack_timestamp);
1095
    first = false;
1096
    if (!first) sb.append(", ");
1097
    sb.append("bank_status:");
1098
    if (this.bank_status == null) {
1099
      sb.append("null");
1100
    } else {
1101
      sb.append(this.bank_status);
1102
    }
1103
    first = false;
1104
    if (!first) sb.append(", ");
1105
    sb.append("status:");
1106
    if (this.status == null) {
1107
      sb.append("null");
1108
    } else {
1109
      String status_name = status.name();
1110
      if (status_name != null) {
1111
        sb.append(status_name);
1112
        sb.append(" (");
1113
      }
1114
      sb.append(this.status);
1115
      if (status_name != null) {
1116
        sb.append(")");
1117
      }
1118
    }
1119
    first = false;
1120
    if (!first) sb.append(", ");
1121
    sb.append("message:");
1122
    if (this.message == null) {
1123
      sb.append("null");
1124
    } else {
1125
      sb.append(this.message);
1126
    }
1127
    first = false;
1128
    if (!first) sb.append(", ");
1129
    sb.append("user_id:");
1130
    sb.append(this.user_id);
1131
    first = false;
1132
    if (!first) sb.append(", ");
1133
    sb.append("cart_id:");
1134
    sb.append(this.cart_id);
1135
    first = false;
1136
    if (!first) sb.append(", ");
1137
    sb.append("other_info:");
1138
    if (this.other_info == null) {
1139
      sb.append("null");
1140
    } else {
1141
      sb.append(this.other_info);
1142
    }
1143
    first = false;
1144
    if (!first) sb.append(", ");
1145
    sb.append("gateway:");
1146
    if (this.gateway == null) {
1147
      sb.append("null");
1148
    } else {
1149
      String gateway_name = gateway.name();
1150
      if (gateway_name != null) {
1151
        sb.append(gateway_name);
1152
        sb.append(" (");
1153
      }
1154
      sb.append(this.gateway);
1155
      if (gateway_name != null) {
1156
        sb.append(")");
1157
      }
1158
    }
1159
    first = false;
1160
    sb.append(")");
1161
    return sb.toString();
1162
  }
1163
 
1164
  public void validate() throws TException {
1165
    // check for required fields
1166
  }
1167
 
1168
}
1169