Subversion Repositories SmartDukaan

Rev

Rev 68 | Blame | Last modification | View Log | RSS feed

/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package in.shop2020.model.v1.order;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.thrift.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.protocol.*;

public class Payment implements TBase<Payment._Fields>, java.io.Serializable, Cloneable, Comparable<Payment> {
  private static final TStruct STRUCT_DESC = new TStruct("Payment");

  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
  private static final TField MERCHANT_TX_ID_FIELD_DESC = new TField("merchant_tx_id", TType.STRING, (short)2);
  private static final TField BANK_TX_ID_FIELD_DESC = new TField("bank_tx_id", TType.STRING, (short)3);
  private static final TField MODE_FIELD_DESC = new TField("mode", TType.STRING, (short)4);
  private static final TField AMOUNT_FIELD_DESC = new TField("amount", TType.DOUBLE, (short)5);
  private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)6);
  private static final TField DESCRIPTION_FIELD_DESC = new TField("description", TType.STRING, (short)7);
  private static final TField SUBMISSION_TIMESTAMP_FIELD_DESC = new TField("submissionTimestamp", TType.I64, (short)9);
  private static final TField COMPLETION_TIMESTAMP_FIELD_DESC = new TField("completionTimestamp", TType.I64, (short)10);

  private long id;
  private String merchant_tx_id;
  private String bank_tx_id;
  private String mode;
  private double amount;
  private PaymentStatus status;
  private String description;
  private long submissionTimestamp;
  private long completionTimestamp;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    ID((short)1, "id"),
    MERCHANT_TX_ID((short)2, "merchant_tx_id"),
    BANK_TX_ID((short)3, "bank_tx_id"),
    MODE((short)4, "mode"),
    AMOUNT((short)5, "amount"),
    /**
     * 
     * @see PaymentStatus
     */
    STATUS((short)6, "status"),
    DESCRIPTION((short)7, "description"),
    SUBMISSION_TIMESTAMP((short)9, "submissionTimestamp"),
    COMPLETION_TIMESTAMP((short)10, "completionTimestamp");

    private static final Map<Integer, _Fields> byId = new HashMap<Integer, _Fields>();
    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

    static {
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
        byId.put((int)field._thriftId, field);
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      return byId.get(fieldId);
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    public static _Fields findByName(String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final String _fieldName;

    _Fields(short thriftId, String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __ID_ISSET_ID = 0;
  private static final int __AMOUNT_ISSET_ID = 1;
  private static final int __SUBMISSIONTIMESTAMP_ISSET_ID = 2;
  private static final int __COMPLETIONTIMESTAMP_ISSET_ID = 3;
  private BitSet __isset_bit_vector = new BitSet(4);

  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    put(_Fields.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.MERCHANT_TX_ID, new FieldMetaData("merchant_tx_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.BANK_TX_ID, new FieldMetaData("bank_tx_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.MODE, new FieldMetaData("mode", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.AMOUNT, new FieldMetaData("amount", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
    put(_Fields.STATUS, new FieldMetaData("status", TFieldRequirementType.DEFAULT, 
        new EnumMetaData(TType.ENUM, PaymentStatus.class)));
    put(_Fields.DESCRIPTION, new FieldMetaData("description", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.SUBMISSION_TIMESTAMP, new FieldMetaData("submissionTimestamp", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.COMPLETION_TIMESTAMP, new FieldMetaData("completionTimestamp", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
  }});

  static {
    FieldMetaData.addStructMetaDataMap(Payment.class, metaDataMap);
  }

  public Payment() {
  }

  public Payment(
    long id,
    String merchant_tx_id,
    String bank_tx_id,
    String mode,
    double amount,
    PaymentStatus status,
    String description,
    long submissionTimestamp,
    long completionTimestamp)
  {
    this();
    this.id = id;
    setIdIsSet(true);
    this.merchant_tx_id = merchant_tx_id;
    this.bank_tx_id = bank_tx_id;
    this.mode = mode;
    this.amount = amount;
    setAmountIsSet(true);
    this.status = status;
    this.description = description;
    this.submissionTimestamp = submissionTimestamp;
    setSubmissionTimestampIsSet(true);
    this.completionTimestamp = completionTimestamp;
    setCompletionTimestampIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Payment(Payment other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.id = other.id;
    if (other.isSetMerchant_tx_id()) {
      this.merchant_tx_id = other.merchant_tx_id;
    }
    if (other.isSetBank_tx_id()) {
      this.bank_tx_id = other.bank_tx_id;
    }
    if (other.isSetMode()) {
      this.mode = other.mode;
    }
    this.amount = other.amount;
    if (other.isSetStatus()) {
      this.status = other.status;
    }
    if (other.isSetDescription()) {
      this.description = other.description;
    }
    this.submissionTimestamp = other.submissionTimestamp;
    this.completionTimestamp = other.completionTimestamp;
  }

  public Payment deepCopy() {
    return new Payment(this);
  }

  @Deprecated
  public Payment clone() {
    return new Payment(this);
  }

  public long getId() {
    return this.id;
  }

  public Payment setId(long id) {
    this.id = id;
    setIdIsSet(true);
    return this;
  }

  public void unsetId() {
    __isset_bit_vector.clear(__ID_ISSET_ID);
  }

  /** Returns true if field id is set (has been asigned a value) and false otherwise */
  public boolean isSetId() {
    return __isset_bit_vector.get(__ID_ISSET_ID);
  }

  public void setIdIsSet(boolean value) {
    __isset_bit_vector.set(__ID_ISSET_ID, value);
  }

  public String getMerchant_tx_id() {
    return this.merchant_tx_id;
  }

  public Payment setMerchant_tx_id(String merchant_tx_id) {
    this.merchant_tx_id = merchant_tx_id;
    return this;
  }

  public void unsetMerchant_tx_id() {
    this.merchant_tx_id = null;
  }

  /** Returns true if field merchant_tx_id is set (has been asigned a value) and false otherwise */
  public boolean isSetMerchant_tx_id() {
    return this.merchant_tx_id != null;
  }

  public void setMerchant_tx_idIsSet(boolean value) {
    if (!value) {
      this.merchant_tx_id = null;
    }
  }

  public String getBank_tx_id() {
    return this.bank_tx_id;
  }

  public Payment setBank_tx_id(String bank_tx_id) {
    this.bank_tx_id = bank_tx_id;
    return this;
  }

  public void unsetBank_tx_id() {
    this.bank_tx_id = null;
  }

  /** Returns true if field bank_tx_id is set (has been asigned a value) and false otherwise */
  public boolean isSetBank_tx_id() {
    return this.bank_tx_id != null;
  }

  public void setBank_tx_idIsSet(boolean value) {
    if (!value) {
      this.bank_tx_id = null;
    }
  }

  public String getMode() {
    return this.mode;
  }

  public Payment setMode(String mode) {
    this.mode = mode;
    return this;
  }

  public void unsetMode() {
    this.mode = null;
  }

  /** Returns true if field mode is set (has been asigned a value) and false otherwise */
  public boolean isSetMode() {
    return this.mode != null;
  }

  public void setModeIsSet(boolean value) {
    if (!value) {
      this.mode = null;
    }
  }

  public double getAmount() {
    return this.amount;
  }

  public Payment setAmount(double amount) {
    this.amount = amount;
    setAmountIsSet(true);
    return this;
  }

  public void unsetAmount() {
    __isset_bit_vector.clear(__AMOUNT_ISSET_ID);
  }

  /** Returns true if field amount is set (has been asigned a value) and false otherwise */
  public boolean isSetAmount() {
    return __isset_bit_vector.get(__AMOUNT_ISSET_ID);
  }

  public void setAmountIsSet(boolean value) {
    __isset_bit_vector.set(__AMOUNT_ISSET_ID, value);
  }

  /**
   * 
   * @see PaymentStatus
   */
  public PaymentStatus getStatus() {
    return this.status;
  }

  /**
   * 
   * @see PaymentStatus
   */
  public Payment setStatus(PaymentStatus status) {
    this.status = status;
    return this;
  }

  public void unsetStatus() {
    this.status = null;
  }

  /** Returns true if field status is set (has been asigned a value) and false otherwise */
  public boolean isSetStatus() {
    return this.status != null;
  }

  public void setStatusIsSet(boolean value) {
    if (!value) {
      this.status = null;
    }
  }

  public String getDescription() {
    return this.description;
  }

  public Payment setDescription(String description) {
    this.description = description;
    return this;
  }

  public void unsetDescription() {
    this.description = null;
  }

  /** Returns true if field description is set (has been asigned a value) and false otherwise */
  public boolean isSetDescription() {
    return this.description != null;
  }

  public void setDescriptionIsSet(boolean value) {
    if (!value) {
      this.description = null;
    }
  }

  public long getSubmissionTimestamp() {
    return this.submissionTimestamp;
  }

  public Payment setSubmissionTimestamp(long submissionTimestamp) {
    this.submissionTimestamp = submissionTimestamp;
    setSubmissionTimestampIsSet(true);
    return this;
  }

  public void unsetSubmissionTimestamp() {
    __isset_bit_vector.clear(__SUBMISSIONTIMESTAMP_ISSET_ID);
  }

  /** Returns true if field submissionTimestamp is set (has been asigned a value) and false otherwise */
  public boolean isSetSubmissionTimestamp() {
    return __isset_bit_vector.get(__SUBMISSIONTIMESTAMP_ISSET_ID);
  }

  public void setSubmissionTimestampIsSet(boolean value) {
    __isset_bit_vector.set(__SUBMISSIONTIMESTAMP_ISSET_ID, value);
  }

  public long getCompletionTimestamp() {
    return this.completionTimestamp;
  }

  public Payment setCompletionTimestamp(long completionTimestamp) {
    this.completionTimestamp = completionTimestamp;
    setCompletionTimestampIsSet(true);
    return this;
  }

  public void unsetCompletionTimestamp() {
    __isset_bit_vector.clear(__COMPLETIONTIMESTAMP_ISSET_ID);
  }

  /** Returns true if field completionTimestamp is set (has been asigned a value) and false otherwise */
  public boolean isSetCompletionTimestamp() {
    return __isset_bit_vector.get(__COMPLETIONTIMESTAMP_ISSET_ID);
  }

  public void setCompletionTimestampIsSet(boolean value) {
    __isset_bit_vector.set(__COMPLETIONTIMESTAMP_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case ID:
      if (value == null) {
        unsetId();
      } else {
        setId((Long)value);
      }
      break;

    case MERCHANT_TX_ID:
      if (value == null) {
        unsetMerchant_tx_id();
      } else {
        setMerchant_tx_id((String)value);
      }
      break;

    case BANK_TX_ID:
      if (value == null) {
        unsetBank_tx_id();
      } else {
        setBank_tx_id((String)value);
      }
      break;

    case MODE:
      if (value == null) {
        unsetMode();
      } else {
        setMode((String)value);
      }
      break;

    case AMOUNT:
      if (value == null) {
        unsetAmount();
      } else {
        setAmount((Double)value);
      }
      break;

    case STATUS:
      if (value == null) {
        unsetStatus();
      } else {
        setStatus((PaymentStatus)value);
      }
      break;

    case DESCRIPTION:
      if (value == null) {
        unsetDescription();
      } else {
        setDescription((String)value);
      }
      break;

    case SUBMISSION_TIMESTAMP:
      if (value == null) {
        unsetSubmissionTimestamp();
      } else {
        setSubmissionTimestamp((Long)value);
      }
      break;

    case COMPLETION_TIMESTAMP:
      if (value == null) {
        unsetCompletionTimestamp();
      } else {
        setCompletionTimestamp((Long)value);
      }
      break;

    }
  }

  public void setFieldValue(int fieldID, Object value) {
    setFieldValue(_Fields.findByThriftIdOrThrow(fieldID), value);
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case ID:
      return new Long(getId());

    case MERCHANT_TX_ID:
      return getMerchant_tx_id();

    case BANK_TX_ID:
      return getBank_tx_id();

    case MODE:
      return getMode();

    case AMOUNT:
      return new Double(getAmount());

    case STATUS:
      return getStatus();

    case DESCRIPTION:
      return getDescription();

    case SUBMISSION_TIMESTAMP:
      return new Long(getSubmissionTimestamp());

    case COMPLETION_TIMESTAMP:
      return new Long(getCompletionTimestamp());

    }
    throw new IllegalStateException();
  }

  public Object getFieldValue(int fieldId) {
    return getFieldValue(_Fields.findByThriftIdOrThrow(fieldId));
  }

  /** Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    switch (field) {
    case ID:
      return isSetId();
    case MERCHANT_TX_ID:
      return isSetMerchant_tx_id();
    case BANK_TX_ID:
      return isSetBank_tx_id();
    case MODE:
      return isSetMode();
    case AMOUNT:
      return isSetAmount();
    case STATUS:
      return isSetStatus();
    case DESCRIPTION:
      return isSetDescription();
    case SUBMISSION_TIMESTAMP:
      return isSetSubmissionTimestamp();
    case COMPLETION_TIMESTAMP:
      return isSetCompletionTimestamp();
    }
    throw new IllegalStateException();
  }

  public boolean isSet(int fieldID) {
    return isSet(_Fields.findByThriftIdOrThrow(fieldID));
  }

  @Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof Payment)
      return this.equals((Payment)that);
    return false;
  }

  public boolean equals(Payment that) {
    if (that == null)
      return false;

    boolean this_present_id = true;
    boolean that_present_id = true;
    if (this_present_id || that_present_id) {
      if (!(this_present_id && that_present_id))
        return false;
      if (this.id != that.id)
        return false;
    }

    boolean this_present_merchant_tx_id = true && this.isSetMerchant_tx_id();
    boolean that_present_merchant_tx_id = true && that.isSetMerchant_tx_id();
    if (this_present_merchant_tx_id || that_present_merchant_tx_id) {
      if (!(this_present_merchant_tx_id && that_present_merchant_tx_id))
        return false;
      if (!this.merchant_tx_id.equals(that.merchant_tx_id))
        return false;
    }

    boolean this_present_bank_tx_id = true && this.isSetBank_tx_id();
    boolean that_present_bank_tx_id = true && that.isSetBank_tx_id();
    if (this_present_bank_tx_id || that_present_bank_tx_id) {
      if (!(this_present_bank_tx_id && that_present_bank_tx_id))
        return false;
      if (!this.bank_tx_id.equals(that.bank_tx_id))
        return false;
    }

    boolean this_present_mode = true && this.isSetMode();
    boolean that_present_mode = true && that.isSetMode();
    if (this_present_mode || that_present_mode) {
      if (!(this_present_mode && that_present_mode))
        return false;
      if (!this.mode.equals(that.mode))
        return false;
    }

    boolean this_present_amount = true;
    boolean that_present_amount = true;
    if (this_present_amount || that_present_amount) {
      if (!(this_present_amount && that_present_amount))
        return false;
      if (this.amount != that.amount)
        return false;
    }

    boolean this_present_status = true && this.isSetStatus();
    boolean that_present_status = true && that.isSetStatus();
    if (this_present_status || that_present_status) {
      if (!(this_present_status && that_present_status))
        return false;
      if (!this.status.equals(that.status))
        return false;
    }

    boolean this_present_description = true && this.isSetDescription();
    boolean that_present_description = true && that.isSetDescription();
    if (this_present_description || that_present_description) {
      if (!(this_present_description && that_present_description))
        return false;
      if (!this.description.equals(that.description))
        return false;
    }

    boolean this_present_submissionTimestamp = true;
    boolean that_present_submissionTimestamp = true;
    if (this_present_submissionTimestamp || that_present_submissionTimestamp) {
      if (!(this_present_submissionTimestamp && that_present_submissionTimestamp))
        return false;
      if (this.submissionTimestamp != that.submissionTimestamp)
        return false;
    }

    boolean this_present_completionTimestamp = true;
    boolean that_present_completionTimestamp = true;
    if (this_present_completionTimestamp || that_present_completionTimestamp) {
      if (!(this_present_completionTimestamp && that_present_completionTimestamp))
        return false;
      if (this.completionTimestamp != that.completionTimestamp)
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    return 0;
  }

  public int compareTo(Payment other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;
    Payment typedOther = (Payment)other;

    lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(id, typedOther.id);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetMerchant_tx_id()).compareTo(isSetMerchant_tx_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(merchant_tx_id, typedOther.merchant_tx_id);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetBank_tx_id()).compareTo(isSetBank_tx_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(bank_tx_id, typedOther.bank_tx_id);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetMode()).compareTo(isSetMode());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(mode, typedOther.mode);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetAmount()).compareTo(isSetAmount());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(amount, typedOther.amount);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetStatus()).compareTo(isSetStatus());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(status, typedOther.status);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetDescription()).compareTo(isSetDescription());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(description, typedOther.description);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetSubmissionTimestamp()).compareTo(isSetSubmissionTimestamp());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(submissionTimestamp, typedOther.submissionTimestamp);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetCompletionTimestamp()).compareTo(isSetCompletionTimestamp());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(completionTimestamp, typedOther.completionTimestamp);
    if (lastComparison != 0) {
      return lastComparison;
    }
    return 0;
  }

  public void read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == TType.STOP) { 
        break;
      }
      _Fields fieldId = _Fields.findByThriftId(field.id);
      if (fieldId == null) {
        TProtocolUtil.skip(iprot, field.type);
      } else {
        switch (fieldId) {
          case ID:
            if (field.type == TType.I64) {
              this.id = iprot.readI64();
              setIdIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case MERCHANT_TX_ID:
            if (field.type == TType.STRING) {
              this.merchant_tx_id = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case BANK_TX_ID:
            if (field.type == TType.STRING) {
              this.bank_tx_id = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case MODE:
            if (field.type == TType.STRING) {
              this.mode = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case AMOUNT:
            if (field.type == TType.DOUBLE) {
              this.amount = iprot.readDouble();
              setAmountIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case STATUS:
            if (field.type == TType.I32) {
              this.status = PaymentStatus.findByValue(iprot.readI32());
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case DESCRIPTION:
            if (field.type == TType.STRING) {
              this.description = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case SUBMISSION_TIMESTAMP:
            if (field.type == TType.I64) {
              this.submissionTimestamp = iprot.readI64();
              setSubmissionTimestampIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case COMPLETION_TIMESTAMP:
            if (field.type == TType.I64) {
              this.completionTimestamp = iprot.readI64();
              setCompletionTimestampIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
        }
        iprot.readFieldEnd();
      }
    }
    iprot.readStructEnd();
    validate();
  }

  public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(ID_FIELD_DESC);
    oprot.writeI64(this.id);
    oprot.writeFieldEnd();
    if (this.merchant_tx_id != null) {
      oprot.writeFieldBegin(MERCHANT_TX_ID_FIELD_DESC);
      oprot.writeString(this.merchant_tx_id);
      oprot.writeFieldEnd();
    }
    if (this.bank_tx_id != null) {
      oprot.writeFieldBegin(BANK_TX_ID_FIELD_DESC);
      oprot.writeString(this.bank_tx_id);
      oprot.writeFieldEnd();
    }
    if (this.mode != null) {
      oprot.writeFieldBegin(MODE_FIELD_DESC);
      oprot.writeString(this.mode);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(AMOUNT_FIELD_DESC);
    oprot.writeDouble(this.amount);
    oprot.writeFieldEnd();
    if (this.status != null) {
      oprot.writeFieldBegin(STATUS_FIELD_DESC);
      oprot.writeI32(this.status.getValue());
      oprot.writeFieldEnd();
    }
    if (this.description != null) {
      oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC);
      oprot.writeString(this.description);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(SUBMISSION_TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.submissionTimestamp);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(COMPLETION_TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.completionTimestamp);
    oprot.writeFieldEnd();
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("Payment(");
    boolean first = true;

    sb.append("id:");
    sb.append(this.id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("merchant_tx_id:");
    if (this.merchant_tx_id == null) {
      sb.append("null");
    } else {
      sb.append(this.merchant_tx_id);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("bank_tx_id:");
    if (this.bank_tx_id == null) {
      sb.append("null");
    } else {
      sb.append(this.bank_tx_id);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("mode:");
    if (this.mode == null) {
      sb.append("null");
    } else {
      sb.append(this.mode);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("amount:");
    sb.append(this.amount);
    first = false;
    if (!first) sb.append(", ");
    sb.append("status:");
    if (this.status == null) {
      sb.append("null");
    } else {
      String status_name = status.name();
      if (status_name != null) {
        sb.append(status_name);
        sb.append(" (");
      }
      sb.append(this.status);
      if (status_name != null) {
        sb.append(")");
      }
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("description:");
    if (this.description == null) {
      sb.append("null");
    } else {
      sb.append(this.description);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("submissionTimestamp:");
    sb.append(this.submissionTimestamp);
    first = false;
    if (!first) sb.append(", ");
    sb.append("completionTimestamp:");
    sb.append(this.completionTimestamp);
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws TException {
    // check for required fields
  }

}