Subversion Repositories SmartDukaan

Rev

Rev 420 | Go to most recent revision | Blame | Compare with Previous | 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.payments;

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 {
  private static final TStruct STRUCT_DESC = new TStruct("Payment");

  private static final TField MERCHANT_TX_ID_FIELD_DESC = new TField("merchant_tx_id", TType.I64, (short)1);
  private static final TField BANK_TX_ID_FIELD_DESC = new TField("bank_tx_id", TType.I64, (short)2);
  private static final TField AMOUNT_FIELD_DESC = new TField("amount", TType.DOUBLE, (short)3);
  private static final TField INIT_TIMESTAMP_FIELD_DESC = new TField("init_timestamp", TType.I64, (short)4);
  private static final TField BANK_ACK_TIMESTAMP_FIELD_DESC = new TField("bank_ack_timestamp", TType.I64, (short)5);
  private static final TField BANK_STATUS_FIELD_DESC = new TField("bank_status", TType.STRING, (short)6);
  private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)7);
  private static final TField MESSAGE_FIELD_DESC = new TField("message", TType.STRING, (short)8);
  private static final TField USER_ID_FIELD_DESC = new TField("user_id", TType.I64, (short)9);
  private static final TField CART_ID_FIELD_DESC = new TField("cart_id", TType.I64, (short)10);
  private static final TField OTHER_INFO_FIELD_DESC = new TField("other_info", TType.MAP, (short)11);
  private static final TField GATEWAY_FIELD_DESC = new TField("gateway", TType.I32, (short)12);

  private long merchant_tx_id;
  private long bank_tx_id;
  private double amount;
  private long init_timestamp;
  private long bank_ack_timestamp;
  private String bank_status;
  private PaymentStatus status;
  private String message;
  private long user_id;
  private long cart_id;
  private Map<String,String> other_info;
  private PaymentGateway gateway;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    MERCHANT_TX_ID((short)1, "merchant_tx_id"),
    BANK_TX_ID((short)2, "bank_tx_id"),
    AMOUNT((short)3, "amount"),
    INIT_TIMESTAMP((short)4, "init_timestamp"),
    BANK_ACK_TIMESTAMP((short)5, "bank_ack_timestamp"),
    BANK_STATUS((short)6, "bank_status"),
    /**
     * 
     * @see PaymentStatus
     */
    STATUS((short)7, "status"),
    MESSAGE((short)8, "message"),
    USER_ID((short)9, "user_id"),
    CART_ID((short)10, "cart_id"),
    OTHER_INFO((short)11, "other_info"),
    /**
     * 
     * @see PaymentGateway
     */
    GATEWAY((short)12, "gateway");

    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 __MERCHANT_TX_ID_ISSET_ID = 0;
  private static final int __BANK_TX_ID_ISSET_ID = 1;
  private static final int __AMOUNT_ISSET_ID = 2;
  private static final int __INIT_TIMESTAMP_ISSET_ID = 3;
  private static final int __BANK_ACK_TIMESTAMP_ISSET_ID = 4;
  private static final int __USER_ID_ISSET_ID = 5;
  private static final int __CART_ID_ISSET_ID = 6;
  private BitSet __isset_bit_vector = new BitSet(7);

  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    put(_Fields.MERCHANT_TX_ID, new FieldMetaData("merchant_tx_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.BANK_TX_ID, new FieldMetaData("bank_tx_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.AMOUNT, new FieldMetaData("amount", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.DOUBLE)));
    put(_Fields.INIT_TIMESTAMP, new FieldMetaData("init_timestamp", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.BANK_ACK_TIMESTAMP, new FieldMetaData("bank_ack_timestamp", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.BANK_STATUS, new FieldMetaData("bank_status", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.STATUS, new FieldMetaData("status", TFieldRequirementType.DEFAULT, 
        new EnumMetaData(TType.ENUM, PaymentStatus.class)));
    put(_Fields.MESSAGE, new FieldMetaData("message", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.USER_ID, new FieldMetaData("user_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.CART_ID, new FieldMetaData("cart_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.OTHER_INFO, new FieldMetaData("other_info", TFieldRequirementType.DEFAULT, 
        new MapMetaData(TType.MAP, 
            new FieldValueMetaData(TType.STRING), 
            new FieldValueMetaData(TType.STRING))));
    put(_Fields.GATEWAY, new FieldMetaData("gateway", TFieldRequirementType.DEFAULT, 
        new EnumMetaData(TType.ENUM, PaymentGateway.class)));
  }});

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

  public Payment() {
  }

  public Payment(
    long merchant_tx_id,
    long bank_tx_id,
    double amount,
    long init_timestamp,
    long bank_ack_timestamp,
    String bank_status,
    PaymentStatus status,
    String message,
    long user_id,
    long cart_id,
    Map<String,String> other_info,
    PaymentGateway gateway)
  {
    this();
    this.merchant_tx_id = merchant_tx_id;
    setMerchant_tx_idIsSet(true);
    this.bank_tx_id = bank_tx_id;
    setBank_tx_idIsSet(true);
    this.amount = amount;
    setAmountIsSet(true);
    this.init_timestamp = init_timestamp;
    setInit_timestampIsSet(true);
    this.bank_ack_timestamp = bank_ack_timestamp;
    setBank_ack_timestampIsSet(true);
    this.bank_status = bank_status;
    this.status = status;
    this.message = message;
    this.user_id = user_id;
    setUser_idIsSet(true);
    this.cart_id = cart_id;
    setCart_idIsSet(true);
    this.other_info = other_info;
    this.gateway = gateway;
  }

  /**
   * 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.merchant_tx_id = other.merchant_tx_id;
    this.bank_tx_id = other.bank_tx_id;
    this.amount = other.amount;
    this.init_timestamp = other.init_timestamp;
    this.bank_ack_timestamp = other.bank_ack_timestamp;
    if (other.isSetBank_status()) {
      this.bank_status = other.bank_status;
    }
    if (other.isSetStatus()) {
      this.status = other.status;
    }
    if (other.isSetMessage()) {
      this.message = other.message;
    }
    this.user_id = other.user_id;
    this.cart_id = other.cart_id;
    if (other.isSetOther_info()) {
      Map<String,String> __this__other_info = new HashMap<String,String>();
      for (Map.Entry<String, String> other_element : other.other_info.entrySet()) {

        String other_element_key = other_element.getKey();
        String other_element_value = other_element.getValue();

        String __this__other_info_copy_key = other_element_key;

        String __this__other_info_copy_value = other_element_value;

        __this__other_info.put(__this__other_info_copy_key, __this__other_info_copy_value);
      }
      this.other_info = __this__other_info;
    }
    if (other.isSetGateway()) {
      this.gateway = other.gateway;
    }
  }

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

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

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

  public Payment setMerchant_tx_id(long merchant_tx_id) {
    this.merchant_tx_id = merchant_tx_id;
    setMerchant_tx_idIsSet(true);
    return this;
  }

  public void unsetMerchant_tx_id() {
    __isset_bit_vector.clear(__MERCHANT_TX_ID_ISSET_ID);
  }

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

  public void setMerchant_tx_idIsSet(boolean value) {
    __isset_bit_vector.set(__MERCHANT_TX_ID_ISSET_ID, value);
  }

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

  public Payment setBank_tx_id(long bank_tx_id) {
    this.bank_tx_id = bank_tx_id;
    setBank_tx_idIsSet(true);
    return this;
  }

  public void unsetBank_tx_id() {
    __isset_bit_vector.clear(__BANK_TX_ID_ISSET_ID);
  }

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

  public void setBank_tx_idIsSet(boolean value) {
    __isset_bit_vector.set(__BANK_TX_ID_ISSET_ID, value);
  }

  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);
  }

  public long getInit_timestamp() {
    return this.init_timestamp;
  }

  public Payment setInit_timestamp(long init_timestamp) {
    this.init_timestamp = init_timestamp;
    setInit_timestampIsSet(true);
    return this;
  }

  public void unsetInit_timestamp() {
    __isset_bit_vector.clear(__INIT_TIMESTAMP_ISSET_ID);
  }

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

  public void setInit_timestampIsSet(boolean value) {
    __isset_bit_vector.set(__INIT_TIMESTAMP_ISSET_ID, value);
  }

  public long getBank_ack_timestamp() {
    return this.bank_ack_timestamp;
  }

  public Payment setBank_ack_timestamp(long bank_ack_timestamp) {
    this.bank_ack_timestamp = bank_ack_timestamp;
    setBank_ack_timestampIsSet(true);
    return this;
  }

  public void unsetBank_ack_timestamp() {
    __isset_bit_vector.clear(__BANK_ACK_TIMESTAMP_ISSET_ID);
  }

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

  public void setBank_ack_timestampIsSet(boolean value) {
    __isset_bit_vector.set(__BANK_ACK_TIMESTAMP_ISSET_ID, value);
  }

  public String getBank_status() {
    return this.bank_status;
  }

  public Payment setBank_status(String bank_status) {
    this.bank_status = bank_status;
    return this;
  }

  public void unsetBank_status() {
    this.bank_status = null;
  }

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

  public void setBank_statusIsSet(boolean value) {
    if (!value) {
      this.bank_status = null;
    }
  }

  /**
   * 
   * @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 getMessage() {
    return this.message;
  }

  public Payment setMessage(String message) {
    this.message = message;
    return this;
  }

  public void unsetMessage() {
    this.message = null;
  }

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

  public void setMessageIsSet(boolean value) {
    if (!value) {
      this.message = null;
    }
  }

  public long getUser_id() {
    return this.user_id;
  }

  public Payment setUser_id(long user_id) {
    this.user_id = user_id;
    setUser_idIsSet(true);
    return this;
  }

  public void unsetUser_id() {
    __isset_bit_vector.clear(__USER_ID_ISSET_ID);
  }

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

  public void setUser_idIsSet(boolean value) {
    __isset_bit_vector.set(__USER_ID_ISSET_ID, value);
  }

  public long getCart_id() {
    return this.cart_id;
  }

  public Payment setCart_id(long cart_id) {
    this.cart_id = cart_id;
    setCart_idIsSet(true);
    return this;
  }

  public void unsetCart_id() {
    __isset_bit_vector.clear(__CART_ID_ISSET_ID);
  }

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

  public void setCart_idIsSet(boolean value) {
    __isset_bit_vector.set(__CART_ID_ISSET_ID, value);
  }

  public int getOther_infoSize() {
    return (this.other_info == null) ? 0 : this.other_info.size();
  }

  public void putToOther_info(String key, String val) {
    if (this.other_info == null) {
      this.other_info = new HashMap<String,String>();
    }
    this.other_info.put(key, val);
  }

  public Map<String,String> getOther_info() {
    return this.other_info;
  }

  public Payment setOther_info(Map<String,String> other_info) {
    this.other_info = other_info;
    return this;
  }

  public void unsetOther_info() {
    this.other_info = null;
  }

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

  public void setOther_infoIsSet(boolean value) {
    if (!value) {
      this.other_info = null;
    }
  }

  /**
   * 
   * @see PaymentGateway
   */
  public PaymentGateway getGateway() {
    return this.gateway;
  }

  /**
   * 
   * @see PaymentGateway
   */
  public Payment setGateway(PaymentGateway gateway) {
    this.gateway = gateway;
    return this;
  }

  public void unsetGateway() {
    this.gateway = null;
  }

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

  public void setGatewayIsSet(boolean value) {
    if (!value) {
      this.gateway = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case MERCHANT_TX_ID:
      if (value == null) {
        unsetMerchant_tx_id();
      } else {
        setMerchant_tx_id((Long)value);
      }
      break;

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

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

    case INIT_TIMESTAMP:
      if (value == null) {
        unsetInit_timestamp();
      } else {
        setInit_timestamp((Long)value);
      }
      break;

    case BANK_ACK_TIMESTAMP:
      if (value == null) {
        unsetBank_ack_timestamp();
      } else {
        setBank_ack_timestamp((Long)value);
      }
      break;

    case BANK_STATUS:
      if (value == null) {
        unsetBank_status();
      } else {
        setBank_status((String)value);
      }
      break;

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

    case MESSAGE:
      if (value == null) {
        unsetMessage();
      } else {
        setMessage((String)value);
      }
      break;

    case USER_ID:
      if (value == null) {
        unsetUser_id();
      } else {
        setUser_id((Long)value);
      }
      break;

    case CART_ID:
      if (value == null) {
        unsetCart_id();
      } else {
        setCart_id((Long)value);
      }
      break;

    case OTHER_INFO:
      if (value == null) {
        unsetOther_info();
      } else {
        setOther_info((Map<String,String>)value);
      }
      break;

    case GATEWAY:
      if (value == null) {
        unsetGateway();
      } else {
        setGateway((PaymentGateway)value);
      }
      break;

    }
  }

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

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case MERCHANT_TX_ID:
      return new Long(getMerchant_tx_id());

    case BANK_TX_ID:
      return new Long(getBank_tx_id());

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

    case INIT_TIMESTAMP:
      return new Long(getInit_timestamp());

    case BANK_ACK_TIMESTAMP:
      return new Long(getBank_ack_timestamp());

    case BANK_STATUS:
      return getBank_status();

    case STATUS:
      return getStatus();

    case MESSAGE:
      return getMessage();

    case USER_ID:
      return new Long(getUser_id());

    case CART_ID:
      return new Long(getCart_id());

    case OTHER_INFO:
      return getOther_info();

    case GATEWAY:
      return getGateway();

    }
    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 MERCHANT_TX_ID:
      return isSetMerchant_tx_id();
    case BANK_TX_ID:
      return isSetBank_tx_id();
    case AMOUNT:
      return isSetAmount();
    case INIT_TIMESTAMP:
      return isSetInit_timestamp();
    case BANK_ACK_TIMESTAMP:
      return isSetBank_ack_timestamp();
    case BANK_STATUS:
      return isSetBank_status();
    case STATUS:
      return isSetStatus();
    case MESSAGE:
      return isSetMessage();
    case USER_ID:
      return isSetUser_id();
    case CART_ID:
      return isSetCart_id();
    case OTHER_INFO:
      return isSetOther_info();
    case GATEWAY:
      return isSetGateway();
    }
    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_merchant_tx_id = true;
    boolean that_present_merchant_tx_id = true;
    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 != that.merchant_tx_id)
        return false;
    }

    boolean this_present_bank_tx_id = true;
    boolean that_present_bank_tx_id = true;
    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 != that.bank_tx_id)
        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_init_timestamp = true;
    boolean that_present_init_timestamp = true;
    if (this_present_init_timestamp || that_present_init_timestamp) {
      if (!(this_present_init_timestamp && that_present_init_timestamp))
        return false;
      if (this.init_timestamp != that.init_timestamp)
        return false;
    }

    boolean this_present_bank_ack_timestamp = true;
    boolean that_present_bank_ack_timestamp = true;
    if (this_present_bank_ack_timestamp || that_present_bank_ack_timestamp) {
      if (!(this_present_bank_ack_timestamp && that_present_bank_ack_timestamp))
        return false;
      if (this.bank_ack_timestamp != that.bank_ack_timestamp)
        return false;
    }

    boolean this_present_bank_status = true && this.isSetBank_status();
    boolean that_present_bank_status = true && that.isSetBank_status();
    if (this_present_bank_status || that_present_bank_status) {
      if (!(this_present_bank_status && that_present_bank_status))
        return false;
      if (!this.bank_status.equals(that.bank_status))
        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_message = true && this.isSetMessage();
    boolean that_present_message = true && that.isSetMessage();
    if (this_present_message || that_present_message) {
      if (!(this_present_message && that_present_message))
        return false;
      if (!this.message.equals(that.message))
        return false;
    }

    boolean this_present_user_id = true;
    boolean that_present_user_id = true;
    if (this_present_user_id || that_present_user_id) {
      if (!(this_present_user_id && that_present_user_id))
        return false;
      if (this.user_id != that.user_id)
        return false;
    }

    boolean this_present_cart_id = true;
    boolean that_present_cart_id = true;
    if (this_present_cart_id || that_present_cart_id) {
      if (!(this_present_cart_id && that_present_cart_id))
        return false;
      if (this.cart_id != that.cart_id)
        return false;
    }

    boolean this_present_other_info = true && this.isSetOther_info();
    boolean that_present_other_info = true && that.isSetOther_info();
    if (this_present_other_info || that_present_other_info) {
      if (!(this_present_other_info && that_present_other_info))
        return false;
      if (!this.other_info.equals(that.other_info))
        return false;
    }

    boolean this_present_gateway = true && this.isSetGateway();
    boolean that_present_gateway = true && that.isSetGateway();
    if (this_present_gateway || that_present_gateway) {
      if (!(this_present_gateway && that_present_gateway))
        return false;
      if (!this.gateway.equals(that.gateway))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    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 MERCHANT_TX_ID:
            if (field.type == TType.I64) {
              this.merchant_tx_id = iprot.readI64();
              setMerchant_tx_idIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case BANK_TX_ID:
            if (field.type == TType.I64) {
              this.bank_tx_id = iprot.readI64();
              setBank_tx_idIsSet(true);
            } 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 INIT_TIMESTAMP:
            if (field.type == TType.I64) {
              this.init_timestamp = iprot.readI64();
              setInit_timestampIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case BANK_ACK_TIMESTAMP:
            if (field.type == TType.I64) {
              this.bank_ack_timestamp = iprot.readI64();
              setBank_ack_timestampIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case BANK_STATUS:
            if (field.type == TType.STRING) {
              this.bank_status = iprot.readString();
            } 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 MESSAGE:
            if (field.type == TType.STRING) {
              this.message = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case USER_ID:
            if (field.type == TType.I64) {
              this.user_id = iprot.readI64();
              setUser_idIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case CART_ID:
            if (field.type == TType.I64) {
              this.cart_id = iprot.readI64();
              setCart_idIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case OTHER_INFO:
            if (field.type == TType.MAP) {
              {
                TMap _map0 = iprot.readMapBegin();
                this.other_info = new HashMap<String,String>(2*_map0.size);
                for (int _i1 = 0; _i1 < _map0.size; ++_i1)
                {
                  String _key2;
                  String _val3;
                  _key2 = iprot.readString();
                  _val3 = iprot.readString();
                  this.other_info.put(_key2, _val3);
                }
                iprot.readMapEnd();
              }
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case GATEWAY:
            if (field.type == TType.I32) {
              this.gateway = PaymentGateway.findByValue(iprot.readI32());
            } 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(MERCHANT_TX_ID_FIELD_DESC);
    oprot.writeI64(this.merchant_tx_id);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(BANK_TX_ID_FIELD_DESC);
    oprot.writeI64(this.bank_tx_id);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(AMOUNT_FIELD_DESC);
    oprot.writeDouble(this.amount);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(INIT_TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.init_timestamp);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(BANK_ACK_TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.bank_ack_timestamp);
    oprot.writeFieldEnd();
    if (this.bank_status != null) {
      oprot.writeFieldBegin(BANK_STATUS_FIELD_DESC);
      oprot.writeString(this.bank_status);
      oprot.writeFieldEnd();
    }
    if (this.status != null) {
      oprot.writeFieldBegin(STATUS_FIELD_DESC);
      oprot.writeI32(this.status.getValue());
      oprot.writeFieldEnd();
    }
    if (this.message != null) {
      oprot.writeFieldBegin(MESSAGE_FIELD_DESC);
      oprot.writeString(this.message);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(USER_ID_FIELD_DESC);
    oprot.writeI64(this.user_id);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(CART_ID_FIELD_DESC);
    oprot.writeI64(this.cart_id);
    oprot.writeFieldEnd();
    if (this.other_info != null) {
      oprot.writeFieldBegin(OTHER_INFO_FIELD_DESC);
      {
        oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, this.other_info.size()));
        for (Map.Entry<String, String> _iter4 : this.other_info.entrySet())
        {
          oprot.writeString(_iter4.getKey());
          oprot.writeString(_iter4.getValue());
        }
        oprot.writeMapEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.gateway != null) {
      oprot.writeFieldBegin(GATEWAY_FIELD_DESC);
      oprot.writeI32(this.gateway.getValue());
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("merchant_tx_id:");
    sb.append(this.merchant_tx_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("bank_tx_id:");
    sb.append(this.bank_tx_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("amount:");
    sb.append(this.amount);
    first = false;
    if (!first) sb.append(", ");
    sb.append("init_timestamp:");
    sb.append(this.init_timestamp);
    first = false;
    if (!first) sb.append(", ");
    sb.append("bank_ack_timestamp:");
    sb.append(this.bank_ack_timestamp);
    first = false;
    if (!first) sb.append(", ");
    sb.append("bank_status:");
    if (this.bank_status == null) {
      sb.append("null");
    } else {
      sb.append(this.bank_status);
    }
    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("message:");
    if (this.message == null) {
      sb.append("null");
    } else {
      sb.append(this.message);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("user_id:");
    sb.append(this.user_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("cart_id:");
    sb.append(this.cart_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("other_info:");
    if (this.other_info == null) {
      sb.append("null");
    } else {
      sb.append(this.other_info);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("gateway:");
    if (this.gateway == null) {
      sb.append("null");
    } else {
      String gateway_name = gateway.name();
      if (gateway_name != null) {
        sb.append(gateway_name);
        sb.append(" (");
      }
      sb.append(this.gateway);
      if (gateway_name != null) {
        sb.append(")");
      }
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

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

}