Subversion Repositories SmartDukaan

Rev

Rev 2219 | Rev 3430 | 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.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 Transaction implements TBase<Transaction._Fields>, java.io.Serializable, Cloneable, Comparable<Transaction> {
  private static final TStruct STRUCT_DESC = new TStruct("Transaction");

  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
  private static final TField ORDERS_FIELD_DESC = new TField("orders", TType.LIST, (short)2);
  private static final TField CREATED_ON_FIELD_DESC = new TField("createdOn", TType.I64, (short)3);
  private static final TField TRANSACTION_STATUS_FIELD_DESC = new TField("transactionStatus", TType.I32, (short)4);
  private static final TField STATUS_DESCRIPTION_FIELD_DESC = new TField("statusDescription", TType.STRING, (short)5);
  private static final TField SHOPPING_CARTID_FIELD_DESC = new TField("shoppingCartid", TType.I64, (short)6);
  private static final TField CUSTOMER_ID_FIELD_DESC = new TField("customer_id", TType.I64, (short)7);
  private static final TField COUPON_CODE_FIELD_DESC = new TField("coupon_code", TType.STRING, (short)8);
  private static final TField SESSION_SOURCE_FIELD_DESC = new TField("sessionSource", TType.STRING, (short)9);
  private static final TField SESSION_START_TIME_FIELD_DESC = new TField("sessionStartTime", TType.I64, (short)10);

  private long id;
  private List<Order> orders;
  private long createdOn;
  private TransactionStatus transactionStatus;
  private String statusDescription;
  private long shoppingCartid;
  private long customer_id;
  private String coupon_code;
  private String sessionSource;
  private long sessionStartTime;

  /** 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"),
    ORDERS((short)2, "orders"),
    CREATED_ON((short)3, "createdOn"),
    /**
     * 
     * @see TransactionStatus
     */
    TRANSACTION_STATUS((short)4, "transactionStatus"),
    STATUS_DESCRIPTION((short)5, "statusDescription"),
    SHOPPING_CARTID((short)6, "shoppingCartid"),
    CUSTOMER_ID((short)7, "customer_id"),
    COUPON_CODE((short)8, "coupon_code"),
    SESSION_SOURCE((short)9, "sessionSource"),
    SESSION_START_TIME((short)10, "sessionStartTime");

    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 __CREATEDON_ISSET_ID = 1;
  private static final int __SHOPPINGCARTID_ISSET_ID = 2;
  private static final int __CUSTOMER_ID_ISSET_ID = 3;
  private static final int __SESSIONSTARTTIME_ISSET_ID = 4;
  private BitSet __isset_bit_vector = new BitSet(5);

  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.ORDERS, new FieldMetaData("orders", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new StructMetaData(TType.STRUCT, Order.class))));
    put(_Fields.CREATED_ON, new FieldMetaData("createdOn", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.TRANSACTION_STATUS, new FieldMetaData("transactionStatus", TFieldRequirementType.DEFAULT, 
        new EnumMetaData(TType.ENUM, TransactionStatus.class)));
    put(_Fields.STATUS_DESCRIPTION, new FieldMetaData("statusDescription", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.SHOPPING_CARTID, new FieldMetaData("shoppingCartid", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.CUSTOMER_ID, new FieldMetaData("customer_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.COUPON_CODE, new FieldMetaData("coupon_code", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.SESSION_SOURCE, new FieldMetaData("sessionSource", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.SESSION_START_TIME, new FieldMetaData("sessionStartTime", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
  }});

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

  public Transaction() {
  }

  public Transaction(
    long id,
    List<Order> orders,
    long createdOn,
    TransactionStatus transactionStatus,
    String statusDescription,
    long shoppingCartid,
    long customer_id,
    String coupon_code,
    String sessionSource,
    long sessionStartTime)
  {
    this();
    this.id = id;
    setIdIsSet(true);
    this.orders = orders;
    this.createdOn = createdOn;
    setCreatedOnIsSet(true);
    this.transactionStatus = transactionStatus;
    this.statusDescription = statusDescription;
    this.shoppingCartid = shoppingCartid;
    setShoppingCartidIsSet(true);
    this.customer_id = customer_id;
    setCustomer_idIsSet(true);
    this.coupon_code = coupon_code;
    this.sessionSource = sessionSource;
    this.sessionStartTime = sessionStartTime;
    setSessionStartTimeIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Transaction(Transaction other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.id = other.id;
    if (other.isSetOrders()) {
      List<Order> __this__orders = new ArrayList<Order>();
      for (Order other_element : other.orders) {
        __this__orders.add(new Order(other_element));
      }
      this.orders = __this__orders;
    }
    this.createdOn = other.createdOn;
    if (other.isSetTransactionStatus()) {
      this.transactionStatus = other.transactionStatus;
    }
    if (other.isSetStatusDescription()) {
      this.statusDescription = other.statusDescription;
    }
    this.shoppingCartid = other.shoppingCartid;
    this.customer_id = other.customer_id;
    if (other.isSetCoupon_code()) {
      this.coupon_code = other.coupon_code;
    }
    if (other.isSetSessionSource()) {
      this.sessionSource = other.sessionSource;
    }
    this.sessionStartTime = other.sessionStartTime;
  }

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

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

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

  public Transaction 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 int getOrdersSize() {
    return (this.orders == null) ? 0 : this.orders.size();
  }

  public java.util.Iterator<Order> getOrdersIterator() {
    return (this.orders == null) ? null : this.orders.iterator();
  }

  public void addToOrders(Order elem) {
    if (this.orders == null) {
      this.orders = new ArrayList<Order>();
    }
    this.orders.add(elem);
  }

  public List<Order> getOrders() {
    return this.orders;
  }

  public Transaction setOrders(List<Order> orders) {
    this.orders = orders;
    return this;
  }

  public void unsetOrders() {
    this.orders = null;
  }

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

  public void setOrdersIsSet(boolean value) {
    if (!value) {
      this.orders = null;
    }
  }

  public long getCreatedOn() {
    return this.createdOn;
  }

  public Transaction setCreatedOn(long createdOn) {
    this.createdOn = createdOn;
    setCreatedOnIsSet(true);
    return this;
  }

  public void unsetCreatedOn() {
    __isset_bit_vector.clear(__CREATEDON_ISSET_ID);
  }

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

  public void setCreatedOnIsSet(boolean value) {
    __isset_bit_vector.set(__CREATEDON_ISSET_ID, value);
  }

  /**
   * 
   * @see TransactionStatus
   */
  public TransactionStatus getTransactionStatus() {
    return this.transactionStatus;
  }

  /**
   * 
   * @see TransactionStatus
   */
  public Transaction setTransactionStatus(TransactionStatus transactionStatus) {
    this.transactionStatus = transactionStatus;
    return this;
  }

  public void unsetTransactionStatus() {
    this.transactionStatus = null;
  }

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

  public void setTransactionStatusIsSet(boolean value) {
    if (!value) {
      this.transactionStatus = null;
    }
  }

  public String getStatusDescription() {
    return this.statusDescription;
  }

  public Transaction setStatusDescription(String statusDescription) {
    this.statusDescription = statusDescription;
    return this;
  }

  public void unsetStatusDescription() {
    this.statusDescription = null;
  }

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

  public void setStatusDescriptionIsSet(boolean value) {
    if (!value) {
      this.statusDescription = null;
    }
  }

  public long getShoppingCartid() {
    return this.shoppingCartid;
  }

  public Transaction setShoppingCartid(long shoppingCartid) {
    this.shoppingCartid = shoppingCartid;
    setShoppingCartidIsSet(true);
    return this;
  }

  public void unsetShoppingCartid() {
    __isset_bit_vector.clear(__SHOPPINGCARTID_ISSET_ID);
  }

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

  public void setShoppingCartidIsSet(boolean value) {
    __isset_bit_vector.set(__SHOPPINGCARTID_ISSET_ID, value);
  }

  public long getCustomer_id() {
    return this.customer_id;
  }

  public Transaction setCustomer_id(long customer_id) {
    this.customer_id = customer_id;
    setCustomer_idIsSet(true);
    return this;
  }

  public void unsetCustomer_id() {
    __isset_bit_vector.clear(__CUSTOMER_ID_ISSET_ID);
  }

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

  public void setCustomer_idIsSet(boolean value) {
    __isset_bit_vector.set(__CUSTOMER_ID_ISSET_ID, value);
  }

  public String getCoupon_code() {
    return this.coupon_code;
  }

  public Transaction setCoupon_code(String coupon_code) {
    this.coupon_code = coupon_code;
    return this;
  }

  public void unsetCoupon_code() {
    this.coupon_code = null;
  }

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

  public void setCoupon_codeIsSet(boolean value) {
    if (!value) {
      this.coupon_code = null;
    }
  }

  public String getSessionSource() {
    return this.sessionSource;
  }

  public Transaction setSessionSource(String sessionSource) {
    this.sessionSource = sessionSource;
    return this;
  }

  public void unsetSessionSource() {
    this.sessionSource = null;
  }

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

  public void setSessionSourceIsSet(boolean value) {
    if (!value) {
      this.sessionSource = null;
    }
  }

  public long getSessionStartTime() {
    return this.sessionStartTime;
  }

  public Transaction setSessionStartTime(long sessionStartTime) {
    this.sessionStartTime = sessionStartTime;
    setSessionStartTimeIsSet(true);
    return this;
  }

  public void unsetSessionStartTime() {
    __isset_bit_vector.clear(__SESSIONSTARTTIME_ISSET_ID);
  }

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

  public void setSessionStartTimeIsSet(boolean value) {
    __isset_bit_vector.set(__SESSIONSTARTTIME_ISSET_ID, value);
  }

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

    case ORDERS:
      if (value == null) {
        unsetOrders();
      } else {
        setOrders((List<Order>)value);
      }
      break;

    case CREATED_ON:
      if (value == null) {
        unsetCreatedOn();
      } else {
        setCreatedOn((Long)value);
      }
      break;

    case TRANSACTION_STATUS:
      if (value == null) {
        unsetTransactionStatus();
      } else {
        setTransactionStatus((TransactionStatus)value);
      }
      break;

    case STATUS_DESCRIPTION:
      if (value == null) {
        unsetStatusDescription();
      } else {
        setStatusDescription((String)value);
      }
      break;

    case SHOPPING_CARTID:
      if (value == null) {
        unsetShoppingCartid();
      } else {
        setShoppingCartid((Long)value);
      }
      break;

    case CUSTOMER_ID:
      if (value == null) {
        unsetCustomer_id();
      } else {
        setCustomer_id((Long)value);
      }
      break;

    case COUPON_CODE:
      if (value == null) {
        unsetCoupon_code();
      } else {
        setCoupon_code((String)value);
      }
      break;

    case SESSION_SOURCE:
      if (value == null) {
        unsetSessionSource();
      } else {
        setSessionSource((String)value);
      }
      break;

    case SESSION_START_TIME:
      if (value == null) {
        unsetSessionStartTime();
      } else {
        setSessionStartTime((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 ORDERS:
      return getOrders();

    case CREATED_ON:
      return new Long(getCreatedOn());

    case TRANSACTION_STATUS:
      return getTransactionStatus();

    case STATUS_DESCRIPTION:
      return getStatusDescription();

    case SHOPPING_CARTID:
      return new Long(getShoppingCartid());

    case CUSTOMER_ID:
      return new Long(getCustomer_id());

    case COUPON_CODE:
      return getCoupon_code();

    case SESSION_SOURCE:
      return getSessionSource();

    case SESSION_START_TIME:
      return new Long(getSessionStartTime());

    }
    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 ORDERS:
      return isSetOrders();
    case CREATED_ON:
      return isSetCreatedOn();
    case TRANSACTION_STATUS:
      return isSetTransactionStatus();
    case STATUS_DESCRIPTION:
      return isSetStatusDescription();
    case SHOPPING_CARTID:
      return isSetShoppingCartid();
    case CUSTOMER_ID:
      return isSetCustomer_id();
    case COUPON_CODE:
      return isSetCoupon_code();
    case SESSION_SOURCE:
      return isSetSessionSource();
    case SESSION_START_TIME:
      return isSetSessionStartTime();
    }
    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 Transaction)
      return this.equals((Transaction)that);
    return false;
  }

  public boolean equals(Transaction 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_orders = true && this.isSetOrders();
    boolean that_present_orders = true && that.isSetOrders();
    if (this_present_orders || that_present_orders) {
      if (!(this_present_orders && that_present_orders))
        return false;
      if (!this.orders.equals(that.orders))
        return false;
    }

    boolean this_present_createdOn = true;
    boolean that_present_createdOn = true;
    if (this_present_createdOn || that_present_createdOn) {
      if (!(this_present_createdOn && that_present_createdOn))
        return false;
      if (this.createdOn != that.createdOn)
        return false;
    }

    boolean this_present_transactionStatus = true && this.isSetTransactionStatus();
    boolean that_present_transactionStatus = true && that.isSetTransactionStatus();
    if (this_present_transactionStatus || that_present_transactionStatus) {
      if (!(this_present_transactionStatus && that_present_transactionStatus))
        return false;
      if (!this.transactionStatus.equals(that.transactionStatus))
        return false;
    }

    boolean this_present_statusDescription = true && this.isSetStatusDescription();
    boolean that_present_statusDescription = true && that.isSetStatusDescription();
    if (this_present_statusDescription || that_present_statusDescription) {
      if (!(this_present_statusDescription && that_present_statusDescription))
        return false;
      if (!this.statusDescription.equals(that.statusDescription))
        return false;
    }

    boolean this_present_shoppingCartid = true;
    boolean that_present_shoppingCartid = true;
    if (this_present_shoppingCartid || that_present_shoppingCartid) {
      if (!(this_present_shoppingCartid && that_present_shoppingCartid))
        return false;
      if (this.shoppingCartid != that.shoppingCartid)
        return false;
    }

    boolean this_present_customer_id = true;
    boolean that_present_customer_id = true;
    if (this_present_customer_id || that_present_customer_id) {
      if (!(this_present_customer_id && that_present_customer_id))
        return false;
      if (this.customer_id != that.customer_id)
        return false;
    }

    boolean this_present_coupon_code = true && this.isSetCoupon_code();
    boolean that_present_coupon_code = true && that.isSetCoupon_code();
    if (this_present_coupon_code || that_present_coupon_code) {
      if (!(this_present_coupon_code && that_present_coupon_code))
        return false;
      if (!this.coupon_code.equals(that.coupon_code))
        return false;
    }

    boolean this_present_sessionSource = true && this.isSetSessionSource();
    boolean that_present_sessionSource = true && that.isSetSessionSource();
    if (this_present_sessionSource || that_present_sessionSource) {
      if (!(this_present_sessionSource && that_present_sessionSource))
        return false;
      if (!this.sessionSource.equals(that.sessionSource))
        return false;
    }

    boolean this_present_sessionStartTime = true;
    boolean that_present_sessionStartTime = true;
    if (this_present_sessionStartTime || that_present_sessionStartTime) {
      if (!(this_present_sessionStartTime && that_present_sessionStartTime))
        return false;
      if (this.sessionStartTime != that.sessionStartTime)
        return false;
    }

    return true;
  }

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

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

    int lastComparison = 0;
    Transaction typedOther = (Transaction)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(isSetOrders()).compareTo(isSetOrders());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(orders, typedOther.orders);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetCreatedOn()).compareTo(isSetCreatedOn());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(createdOn, typedOther.createdOn);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetTransactionStatus()).compareTo(isSetTransactionStatus());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(transactionStatus, typedOther.transactionStatus);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetStatusDescription()).compareTo(isSetStatusDescription());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(statusDescription, typedOther.statusDescription);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetShoppingCartid()).compareTo(isSetShoppingCartid());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(shoppingCartid, typedOther.shoppingCartid);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetCustomer_id()).compareTo(isSetCustomer_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(customer_id, typedOther.customer_id);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetCoupon_code()).compareTo(isSetCoupon_code());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(coupon_code, typedOther.coupon_code);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetSessionSource()).compareTo(isSetSessionSource());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(sessionSource, typedOther.sessionSource);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetSessionStartTime()).compareTo(isSetSessionStartTime());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(sessionStartTime, typedOther.sessionStartTime);
    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 ORDERS:
            if (field.type == TType.LIST) {
              {
                TList _list4 = iprot.readListBegin();
                this.orders = new ArrayList<Order>(_list4.size);
                for (int _i5 = 0; _i5 < _list4.size; ++_i5)
                {
                  Order _elem6;
                  _elem6 = new Order();
                  _elem6.read(iprot);
                  this.orders.add(_elem6);
                }
                iprot.readListEnd();
              }
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case CREATED_ON:
            if (field.type == TType.I64) {
              this.createdOn = iprot.readI64();
              setCreatedOnIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case TRANSACTION_STATUS:
            if (field.type == TType.I32) {
              this.transactionStatus = TransactionStatus.findByValue(iprot.readI32());
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case STATUS_DESCRIPTION:
            if (field.type == TType.STRING) {
              this.statusDescription = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case SHOPPING_CARTID:
            if (field.type == TType.I64) {
              this.shoppingCartid = iprot.readI64();
              setShoppingCartidIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case CUSTOMER_ID:
            if (field.type == TType.I64) {
              this.customer_id = iprot.readI64();
              setCustomer_idIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case COUPON_CODE:
            if (field.type == TType.STRING) {
              this.coupon_code = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case SESSION_SOURCE:
            if (field.type == TType.STRING) {
              this.sessionSource = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case SESSION_START_TIME:
            if (field.type == TType.I64) {
              this.sessionStartTime = iprot.readI64();
              setSessionStartTimeIsSet(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.orders != null) {
      oprot.writeFieldBegin(ORDERS_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRUCT, this.orders.size()));
        for (Order _iter7 : this.orders)
        {
          _iter7.write(oprot);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(CREATED_ON_FIELD_DESC);
    oprot.writeI64(this.createdOn);
    oprot.writeFieldEnd();
    if (this.transactionStatus != null) {
      oprot.writeFieldBegin(TRANSACTION_STATUS_FIELD_DESC);
      oprot.writeI32(this.transactionStatus.getValue());
      oprot.writeFieldEnd();
    }
    if (this.statusDescription != null) {
      oprot.writeFieldBegin(STATUS_DESCRIPTION_FIELD_DESC);
      oprot.writeString(this.statusDescription);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(SHOPPING_CARTID_FIELD_DESC);
    oprot.writeI64(this.shoppingCartid);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(CUSTOMER_ID_FIELD_DESC);
    oprot.writeI64(this.customer_id);
    oprot.writeFieldEnd();
    if (this.coupon_code != null) {
      oprot.writeFieldBegin(COUPON_CODE_FIELD_DESC);
      oprot.writeString(this.coupon_code);
      oprot.writeFieldEnd();
    }
    if (this.sessionSource != null) {
      oprot.writeFieldBegin(SESSION_SOURCE_FIELD_DESC);
      oprot.writeString(this.sessionSource);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(SESSION_START_TIME_FIELD_DESC);
    oprot.writeI64(this.sessionStartTime);
    oprot.writeFieldEnd();
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("id:");
    sb.append(this.id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("orders:");
    if (this.orders == null) {
      sb.append("null");
    } else {
      sb.append(this.orders);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("createdOn:");
    sb.append(this.createdOn);
    first = false;
    if (!first) sb.append(", ");
    sb.append("transactionStatus:");
    if (this.transactionStatus == null) {
      sb.append("null");
    } else {
      String transactionStatus_name = transactionStatus.name();
      if (transactionStatus_name != null) {
        sb.append(transactionStatus_name);
        sb.append(" (");
      }
      sb.append(this.transactionStatus);
      if (transactionStatus_name != null) {
        sb.append(")");
      }
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("statusDescription:");
    if (this.statusDescription == null) {
      sb.append("null");
    } else {
      sb.append(this.statusDescription);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("shoppingCartid:");
    sb.append(this.shoppingCartid);
    first = false;
    if (!first) sb.append(", ");
    sb.append("customer_id:");
    sb.append(this.customer_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("coupon_code:");
    if (this.coupon_code == null) {
      sb.append("null");
    } else {
      sb.append(this.coupon_code);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("sessionSource:");
    if (this.sessionSource == null) {
      sb.append("null");
    } else {
      sb.append(this.sessionSource);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("sessionStartTime:");
    sb.append(this.sessionStartTime);
    first = false;
    sb.append(")");
    return sb.toString();
  }

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

}