Subversion Repositories SmartDukaan

Rev

Rev 2981 | 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.user;

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 PromotionService {

  /**
   * Promotion Service
   */
  public interface Iface extends in.shop2020.generic.GenericService.Iface {

    /**
     * For closing the open session in sqlalchemy
     */
    public void closeSession() throws TException;

    public void createPromotion(String name, String ruleExecutionSrc, long startOn, long endOn) throws PromotionException, TException;

    public List<Promotion> getAllPromotions() throws PromotionException, TException;

    public Promotion getPromotionById(long promotionId) throws PromotionException, TException;

    public void generateCouponsForPromotion(long promotionId, String couponCode) throws PromotionException, TException;

    public Cart applyCoupon(String couponCode, long cartId) throws PromotionException, TException;

    public void trackCouponUsage(String couponCode, long transactionId, long userId) throws PromotionException, TException;

    public long getCouponUsageCountByUser(String couponCode, long userId) throws PromotionException, TException;

  }

  public static class Client extends in.shop2020.generic.GenericService.Client implements Iface {
    public Client(TProtocol prot)
    {
      this(prot, prot);
    }

    public Client(TProtocol iprot, TProtocol oprot)
    {
      super(iprot, oprot);
    }

    public void closeSession() throws TException
    {
      send_closeSession();
      recv_closeSession();
    }

    public void send_closeSession() throws TException
    {
      oprot_.writeMessageBegin(new TMessage("closeSession", TMessageType.CALL, seqid_));
      closeSession_args args = new closeSession_args();
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_closeSession() throws TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      closeSession_result result = new closeSession_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      return;
    }

    public void createPromotion(String name, String ruleExecutionSrc, long startOn, long endOn) throws PromotionException, TException
    {
      send_createPromotion(name, ruleExecutionSrc, startOn, endOn);
      recv_createPromotion();
    }

    public void send_createPromotion(String name, String ruleExecutionSrc, long startOn, long endOn) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("createPromotion", TMessageType.CALL, seqid_));
      createPromotion_args args = new createPromotion_args();
      args.name = name;
      args.ruleExecutionSrc = ruleExecutionSrc;
      args.startOn = startOn;
      args.endOn = endOn;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_createPromotion() throws PromotionException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      createPromotion_result result = new createPromotion_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.pex != null) {
        throw result.pex;
      }
      return;
    }

    public List<Promotion> getAllPromotions() throws PromotionException, TException
    {
      send_getAllPromotions();
      return recv_getAllPromotions();
    }

    public void send_getAllPromotions() throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getAllPromotions", TMessageType.CALL, seqid_));
      getAllPromotions_args args = new getAllPromotions_args();
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public List<Promotion> recv_getAllPromotions() throws PromotionException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getAllPromotions_result result = new getAllPromotions_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pex != null) {
        throw result.pex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getAllPromotions failed: unknown result");
    }

    public Promotion getPromotionById(long promotionId) throws PromotionException, TException
    {
      send_getPromotionById(promotionId);
      return recv_getPromotionById();
    }

    public void send_getPromotionById(long promotionId) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getPromotionById", TMessageType.CALL, seqid_));
      getPromotionById_args args = new getPromotionById_args();
      args.promotionId = promotionId;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public Promotion recv_getPromotionById() throws PromotionException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getPromotionById_result result = new getPromotionById_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pex != null) {
        throw result.pex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getPromotionById failed: unknown result");
    }

    public void generateCouponsForPromotion(long promotionId, String couponCode) throws PromotionException, TException
    {
      send_generateCouponsForPromotion(promotionId, couponCode);
      recv_generateCouponsForPromotion();
    }

    public void send_generateCouponsForPromotion(long promotionId, String couponCode) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("generateCouponsForPromotion", TMessageType.CALL, seqid_));
      generateCouponsForPromotion_args args = new generateCouponsForPromotion_args();
      args.promotionId = promotionId;
      args.couponCode = couponCode;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_generateCouponsForPromotion() throws PromotionException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      generateCouponsForPromotion_result result = new generateCouponsForPromotion_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.pex != null) {
        throw result.pex;
      }
      return;
    }

    public Cart applyCoupon(String couponCode, long cartId) throws PromotionException, TException
    {
      send_applyCoupon(couponCode, cartId);
      return recv_applyCoupon();
    }

    public void send_applyCoupon(String couponCode, long cartId) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("applyCoupon", TMessageType.CALL, seqid_));
      applyCoupon_args args = new applyCoupon_args();
      args.couponCode = couponCode;
      args.cartId = cartId;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public Cart recv_applyCoupon() throws PromotionException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      applyCoupon_result result = new applyCoupon_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pex != null) {
        throw result.pex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "applyCoupon failed: unknown result");
    }

    public void trackCouponUsage(String couponCode, long transactionId, long userId) throws PromotionException, TException
    {
      send_trackCouponUsage(couponCode, transactionId, userId);
      recv_trackCouponUsage();
    }

    public void send_trackCouponUsage(String couponCode, long transactionId, long userId) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("trackCouponUsage", TMessageType.CALL, seqid_));
      trackCouponUsage_args args = new trackCouponUsage_args();
      args.couponCode = couponCode;
      args.transactionId = transactionId;
      args.userId = userId;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public void recv_trackCouponUsage() throws PromotionException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      trackCouponUsage_result result = new trackCouponUsage_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.pex != null) {
        throw result.pex;
      }
      return;
    }

    public long getCouponUsageCountByUser(String couponCode, long userId) throws PromotionException, TException
    {
      send_getCouponUsageCountByUser(couponCode, userId);
      return recv_getCouponUsageCountByUser();
    }

    public void send_getCouponUsageCountByUser(String couponCode, long userId) throws TException
    {
      oprot_.writeMessageBegin(new TMessage("getCouponUsageCountByUser", TMessageType.CALL, seqid_));
      getCouponUsageCountByUser_args args = new getCouponUsageCountByUser_args();
      args.couponCode = couponCode;
      args.userId = userId;
      args.write(oprot_);
      oprot_.writeMessageEnd();
      oprot_.getTransport().flush();
    }

    public long recv_getCouponUsageCountByUser() throws PromotionException, TException
    {
      TMessage msg = iprot_.readMessageBegin();
      if (msg.type == TMessageType.EXCEPTION) {
        TApplicationException x = TApplicationException.read(iprot_);
        iprot_.readMessageEnd();
        throw x;
      }
      getCouponUsageCountByUser_result result = new getCouponUsageCountByUser_result();
      result.read(iprot_);
      iprot_.readMessageEnd();
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.pex != null) {
        throw result.pex;
      }
      throw new TApplicationException(TApplicationException.MISSING_RESULT, "getCouponUsageCountByUser failed: unknown result");
    }

  }
  public static class Processor extends in.shop2020.generic.GenericService.Processor implements TProcessor {
    private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
    public Processor(Iface iface)
    {
      super(iface);
      iface_ = iface;
      processMap_.put("closeSession", new closeSession());
      processMap_.put("createPromotion", new createPromotion());
      processMap_.put("getAllPromotions", new getAllPromotions());
      processMap_.put("getPromotionById", new getPromotionById());
      processMap_.put("generateCouponsForPromotion", new generateCouponsForPromotion());
      processMap_.put("applyCoupon", new applyCoupon());
      processMap_.put("trackCouponUsage", new trackCouponUsage());
      processMap_.put("getCouponUsageCountByUser", new getCouponUsageCountByUser());
    }

    private Iface iface_;

    public boolean process(TProtocol iprot, TProtocol oprot) throws TException
    {
      TMessage msg = iprot.readMessageBegin();
      ProcessFunction fn = processMap_.get(msg.name);
      if (fn == null) {
        TProtocolUtil.skip(iprot, TType.STRUCT);
        iprot.readMessageEnd();
        TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, "Invalid method name: '"+msg.name+"'");
        oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
        x.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
        return true;
      }
      fn.process(msg.seqid, iprot, oprot);
      return true;
    }

    private class closeSession implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        closeSession_args args = new closeSession_args();
        args.read(iprot);
        iprot.readMessageEnd();
        closeSession_result result = new closeSession_result();
        iface_.closeSession();
        oprot.writeMessageBegin(new TMessage("closeSession", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class createPromotion implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        createPromotion_args args = new createPromotion_args();
        args.read(iprot);
        iprot.readMessageEnd();
        createPromotion_result result = new createPromotion_result();
        try {
          iface_.createPromotion(args.name, args.ruleExecutionSrc, args.startOn, args.endOn);
        } catch (PromotionException pex) {
          result.pex = pex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing createPromotion", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing createPromotion");
          oprot.writeMessageBegin(new TMessage("createPromotion", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("createPromotion", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getAllPromotions implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getAllPromotions_args args = new getAllPromotions_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getAllPromotions_result result = new getAllPromotions_result();
        try {
          result.success = iface_.getAllPromotions();
        } catch (PromotionException pex) {
          result.pex = pex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getAllPromotions", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getAllPromotions");
          oprot.writeMessageBegin(new TMessage("getAllPromotions", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getAllPromotions", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getPromotionById implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getPromotionById_args args = new getPromotionById_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getPromotionById_result result = new getPromotionById_result();
        try {
          result.success = iface_.getPromotionById(args.promotionId);
        } catch (PromotionException pex) {
          result.pex = pex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getPromotionById", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getPromotionById");
          oprot.writeMessageBegin(new TMessage("getPromotionById", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getPromotionById", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class generateCouponsForPromotion implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        generateCouponsForPromotion_args args = new generateCouponsForPromotion_args();
        args.read(iprot);
        iprot.readMessageEnd();
        generateCouponsForPromotion_result result = new generateCouponsForPromotion_result();
        try {
          iface_.generateCouponsForPromotion(args.promotionId, args.couponCode);
        } catch (PromotionException pex) {
          result.pex = pex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing generateCouponsForPromotion", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing generateCouponsForPromotion");
          oprot.writeMessageBegin(new TMessage("generateCouponsForPromotion", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("generateCouponsForPromotion", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class applyCoupon implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        applyCoupon_args args = new applyCoupon_args();
        args.read(iprot);
        iprot.readMessageEnd();
        applyCoupon_result result = new applyCoupon_result();
        try {
          result.success = iface_.applyCoupon(args.couponCode, args.cartId);
        } catch (PromotionException pex) {
          result.pex = pex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing applyCoupon", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing applyCoupon");
          oprot.writeMessageBegin(new TMessage("applyCoupon", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("applyCoupon", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class trackCouponUsage implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        trackCouponUsage_args args = new trackCouponUsage_args();
        args.read(iprot);
        iprot.readMessageEnd();
        trackCouponUsage_result result = new trackCouponUsage_result();
        try {
          iface_.trackCouponUsage(args.couponCode, args.transactionId, args.userId);
        } catch (PromotionException pex) {
          result.pex = pex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing trackCouponUsage", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing trackCouponUsage");
          oprot.writeMessageBegin(new TMessage("trackCouponUsage", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("trackCouponUsage", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

    private class getCouponUsageCountByUser implements ProcessFunction {
      public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException
      {
        getCouponUsageCountByUser_args args = new getCouponUsageCountByUser_args();
        args.read(iprot);
        iprot.readMessageEnd();
        getCouponUsageCountByUser_result result = new getCouponUsageCountByUser_result();
        try {
          result.success = iface_.getCouponUsageCountByUser(args.couponCode, args.userId);
          result.setSuccessIsSet(true);
        } catch (PromotionException pex) {
          result.pex = pex;
        } catch (Throwable th) {
          LOGGER.error("Internal error processing getCouponUsageCountByUser", th);
          TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing getCouponUsageCountByUser");
          oprot.writeMessageBegin(new TMessage("getCouponUsageCountByUser", TMessageType.EXCEPTION, seqid));
          x.write(oprot);
          oprot.writeMessageEnd();
          oprot.getTransport().flush();
          return;
        }
        oprot.writeMessageBegin(new TMessage("getCouponUsageCountByUser", TMessageType.REPLY, seqid));
        result.write(oprot);
        oprot.writeMessageEnd();
        oprot.getTransport().flush();
      }

    }

  }

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



    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
;

      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;
      }
    }
    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    }});

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

    public closeSession_args() {
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public closeSession_args(closeSession_args other) {
    }

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

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

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      }
      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) {
      }
      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 closeSession_args)
        return this.equals((closeSession_args)that);
      return false;
    }

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

      return true;
    }

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

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

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

      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) {
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

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

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append(")");
      return sb.toString();
    }

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

  }

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



    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
;

      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;
      }
    }
    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    }});

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

    public closeSession_result() {
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public closeSession_result(closeSession_result other) {
    }

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

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

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      }
      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) {
      }
      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 closeSession_result)
        return this.equals((closeSession_result)that);
      return false;
    }

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

      return true;
    }

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

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

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

      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) {
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField NAME_FIELD_DESC = new TField("name", TType.STRING, (short)1);
    private static final TField RULE_EXECUTION_SRC_FIELD_DESC = new TField("ruleExecutionSrc", TType.STRING, (short)2);
    private static final TField START_ON_FIELD_DESC = new TField("startOn", TType.I64, (short)3);
    private static final TField END_ON_FIELD_DESC = new TField("endOn", TType.I64, (short)4);

    private String name;
    private String ruleExecutionSrc;
    private long startOn;
    private long endOn;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      NAME((short)1, "name"),
      RULE_EXECUTION_SRC((short)2, "ruleExecutionSrc"),
      START_ON((short)3, "startOn"),
      END_ON((short)4, "endOn");

      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 __STARTON_ISSET_ID = 0;
    private static final int __ENDON_ISSET_ID = 1;
    private BitSet __isset_bit_vector = new BitSet(2);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.NAME, new FieldMetaData("name", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
      put(_Fields.RULE_EXECUTION_SRC, new FieldMetaData("ruleExecutionSrc", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
      put(_Fields.START_ON, new FieldMetaData("startOn", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.END_ON, new FieldMetaData("endOn", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
    }});

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

    public createPromotion_args() {
    }

    public createPromotion_args(
      String name,
      String ruleExecutionSrc,
      long startOn,
      long endOn)
    {
      this();
      this.name = name;
      this.ruleExecutionSrc = ruleExecutionSrc;
      this.startOn = startOn;
      setStartOnIsSet(true);
      this.endOn = endOn;
      setEndOnIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public createPromotion_args(createPromotion_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      if (other.isSetName()) {
        this.name = other.name;
      }
      if (other.isSetRuleExecutionSrc()) {
        this.ruleExecutionSrc = other.ruleExecutionSrc;
      }
      this.startOn = other.startOn;
      this.endOn = other.endOn;
    }

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

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

    public String getName() {
      return this.name;
    }

    public createPromotion_args setName(String name) {
      this.name = name;
      return this;
    }

    public void unsetName() {
      this.name = null;
    }

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

    public void setNameIsSet(boolean value) {
      if (!value) {
        this.name = null;
      }
    }

    public String getRuleExecutionSrc() {
      return this.ruleExecutionSrc;
    }

    public createPromotion_args setRuleExecutionSrc(String ruleExecutionSrc) {
      this.ruleExecutionSrc = ruleExecutionSrc;
      return this;
    }

    public void unsetRuleExecutionSrc() {
      this.ruleExecutionSrc = null;
    }

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

    public void setRuleExecutionSrcIsSet(boolean value) {
      if (!value) {
        this.ruleExecutionSrc = null;
      }
    }

    public long getStartOn() {
      return this.startOn;
    }

    public createPromotion_args setStartOn(long startOn) {
      this.startOn = startOn;
      setStartOnIsSet(true);
      return this;
    }

    public void unsetStartOn() {
      __isset_bit_vector.clear(__STARTON_ISSET_ID);
    }

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

    public void setStartOnIsSet(boolean value) {
      __isset_bit_vector.set(__STARTON_ISSET_ID, value);
    }

    public long getEndOn() {
      return this.endOn;
    }

    public createPromotion_args setEndOn(long endOn) {
      this.endOn = endOn;
      setEndOnIsSet(true);
      return this;
    }

    public void unsetEndOn() {
      __isset_bit_vector.clear(__ENDON_ISSET_ID);
    }

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

    public void setEndOnIsSet(boolean value) {
      __isset_bit_vector.set(__ENDON_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case NAME:
        if (value == null) {
          unsetName();
        } else {
          setName((String)value);
        }
        break;

      case RULE_EXECUTION_SRC:
        if (value == null) {
          unsetRuleExecutionSrc();
        } else {
          setRuleExecutionSrc((String)value);
        }
        break;

      case START_ON:
        if (value == null) {
          unsetStartOn();
        } else {
          setStartOn((Long)value);
        }
        break;

      case END_ON:
        if (value == null) {
          unsetEndOn();
        } else {
          setEndOn((Long)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case NAME:
        return getName();

      case RULE_EXECUTION_SRC:
        return getRuleExecutionSrc();

      case START_ON:
        return new Long(getStartOn());

      case END_ON:
        return new Long(getEndOn());

      }
      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 NAME:
        return isSetName();
      case RULE_EXECUTION_SRC:
        return isSetRuleExecutionSrc();
      case START_ON:
        return isSetStartOn();
      case END_ON:
        return isSetEndOn();
      }
      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 createPromotion_args)
        return this.equals((createPromotion_args)that);
      return false;
    }

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

      boolean this_present_name = true && this.isSetName();
      boolean that_present_name = true && that.isSetName();
      if (this_present_name || that_present_name) {
        if (!(this_present_name && that_present_name))
          return false;
        if (!this.name.equals(that.name))
          return false;
      }

      boolean this_present_ruleExecutionSrc = true && this.isSetRuleExecutionSrc();
      boolean that_present_ruleExecutionSrc = true && that.isSetRuleExecutionSrc();
      if (this_present_ruleExecutionSrc || that_present_ruleExecutionSrc) {
        if (!(this_present_ruleExecutionSrc && that_present_ruleExecutionSrc))
          return false;
        if (!this.ruleExecutionSrc.equals(that.ruleExecutionSrc))
          return false;
      }

      boolean this_present_startOn = true;
      boolean that_present_startOn = true;
      if (this_present_startOn || that_present_startOn) {
        if (!(this_present_startOn && that_present_startOn))
          return false;
        if (this.startOn != that.startOn)
          return false;
      }

      boolean this_present_endOn = true;
      boolean that_present_endOn = true;
      if (this_present_endOn || that_present_endOn) {
        if (!(this_present_endOn && that_present_endOn))
          return false;
        if (this.endOn != that.endOn)
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetName()).compareTo(isSetName());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(name, typedOther.name);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetRuleExecutionSrc()).compareTo(isSetRuleExecutionSrc());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(ruleExecutionSrc, typedOther.ruleExecutionSrc);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetStartOn()).compareTo(isSetStartOn());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(startOn, typedOther.startOn);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetEndOn()).compareTo(isSetEndOn());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(endOn, typedOther.endOn);
      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 NAME:
              if (field.type == TType.STRING) {
                this.name = iprot.readString();
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case RULE_EXECUTION_SRC:
              if (field.type == TType.STRING) {
                this.ruleExecutionSrc = iprot.readString();
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case START_ON:
              if (field.type == TType.I64) {
                this.startOn = iprot.readI64();
                setStartOnIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case END_ON:
              if (field.type == TType.I64) {
                this.endOn = iprot.readI64();
                setEndOnIsSet(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);
      if (this.name != null) {
        oprot.writeFieldBegin(NAME_FIELD_DESC);
        oprot.writeString(this.name);
        oprot.writeFieldEnd();
      }
      if (this.ruleExecutionSrc != null) {
        oprot.writeFieldBegin(RULE_EXECUTION_SRC_FIELD_DESC);
        oprot.writeString(this.ruleExecutionSrc);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(START_ON_FIELD_DESC);
      oprot.writeI64(this.startOn);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(END_ON_FIELD_DESC);
      oprot.writeI64(this.endOn);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("name:");
      if (this.name == null) {
        sb.append("null");
      } else {
        sb.append(this.name);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("ruleExecutionSrc:");
      if (this.ruleExecutionSrc == null) {
        sb.append("null");
      } else {
        sb.append(this.ruleExecutionSrc);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("startOn:");
      sb.append(this.startOn);
      first = false;
      if (!first) sb.append(", ");
      sb.append("endOn:");
      sb.append(this.endOn);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField PEX_FIELD_DESC = new TField("pex", TType.STRUCT, (short)1);

    private PromotionException pex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PEX((short)1, "pex");

      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

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PEX, new FieldMetaData("pex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public createPromotion_result() {
    }

    public createPromotion_result(
      PromotionException pex)
    {
      this();
      this.pex = pex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public createPromotion_result(createPromotion_result other) {
      if (other.isSetPex()) {
        this.pex = new PromotionException(other.pex);
      }
    }

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

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

    public PromotionException getPex() {
      return this.pex;
    }

    public createPromotion_result setPex(PromotionException pex) {
      this.pex = pex;
      return this;
    }

    public void unsetPex() {
      this.pex = null;
    }

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

    public void setPexIsSet(boolean value) {
      if (!value) {
        this.pex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PEX:
        if (value == null) {
          unsetPex();
        } else {
          setPex((PromotionException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PEX:
        return getPex();

      }
      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 PEX:
        return isSetPex();
      }
      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 createPromotion_result)
        return this.equals((createPromotion_result)that);
      return false;
    }

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

      boolean this_present_pex = true && this.isSetPex();
      boolean that_present_pex = true && that.isSetPex();
      if (this_present_pex || that_present_pex) {
        if (!(this_present_pex && that_present_pex))
          return false;
        if (!this.pex.equals(that.pex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetPex()).compareTo(isSetPex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pex, typedOther.pex);
      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 PEX:
              if (field.type == TType.STRUCT) {
                this.pex = new PromotionException();
                this.pex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetPex()) {
        oprot.writeFieldBegin(PEX_FIELD_DESC);
        this.pex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("pex:");
      if (this.pex == null) {
        sb.append("null");
      } else {
        sb.append(this.pex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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



    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
;

      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;
      }
    }
    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    }});

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

    public getAllPromotions_args() {
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getAllPromotions_args(getAllPromotions_args other) {
    }

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

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

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      }
      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) {
      }
      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 getAllPromotions_args)
        return this.equals((getAllPromotions_args)that);
      return false;
    }

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

      return true;
    }

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

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

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

      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) {
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

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

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0);
    private static final TField PEX_FIELD_DESC = new TField("pex", TType.STRUCT, (short)1);

    private List<Promotion> success;
    private PromotionException pex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PEX((short)1, "pex");

      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

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new ListMetaData(TType.LIST, 
              new StructMetaData(TType.STRUCT, Promotion.class))));
      put(_Fields.PEX, new FieldMetaData("pex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public getAllPromotions_result() {
    }

    public getAllPromotions_result(
      List<Promotion> success,
      PromotionException pex)
    {
      this();
      this.success = success;
      this.pex = pex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getAllPromotions_result(getAllPromotions_result other) {
      if (other.isSetSuccess()) {
        List<Promotion> __this__success = new ArrayList<Promotion>();
        for (Promotion other_element : other.success) {
          __this__success.add(new Promotion(other_element));
        }
        this.success = __this__success;
      }
      if (other.isSetPex()) {
        this.pex = new PromotionException(other.pex);
      }
    }

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

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

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

    public java.util.Iterator<Promotion> getSuccessIterator() {
      return (this.success == null) ? null : this.success.iterator();
    }

    public void addToSuccess(Promotion elem) {
      if (this.success == null) {
        this.success = new ArrayList<Promotion>();
      }
      this.success.add(elem);
    }

    public List<Promotion> getSuccess() {
      return this.success;
    }

    public getAllPromotions_result setSuccess(List<Promotion> success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

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

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public PromotionException getPex() {
      return this.pex;
    }

    public getAllPromotions_result setPex(PromotionException pex) {
      this.pex = pex;
      return this;
    }

    public void unsetPex() {
      this.pex = null;
    }

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

    public void setPexIsSet(boolean value) {
      if (!value) {
        this.pex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((List<Promotion>)value);
        }
        break;

      case PEX:
        if (value == null) {
          unsetPex();
        } else {
          setPex((PromotionException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case PEX:
        return getPex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case PEX:
        return isSetPex();
      }
      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 getAllPromotions_result)
        return this.equals((getAllPromotions_result)that);
      return false;
    }

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

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_pex = true && this.isSetPex();
      boolean that_present_pex = true && that.isSetPex();
      if (this_present_pex || that_present_pex) {
        if (!(this_present_pex && that_present_pex))
          return false;
        if (!this.pex.equals(that.pex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetPex()).compareTo(isSetPex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pex, typedOther.pex);
      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 SUCCESS:
              if (field.type == TType.LIST) {
                {
                  TList _list12 = iprot.readListBegin();
                  this.success = new ArrayList<Promotion>(_list12.size);
                  for (int _i13 = 0; _i13 < _list12.size; ++_i13)
                  {
                    Promotion _elem14;
                    _elem14 = new Promotion();
                    _elem14.read(iprot);
                    this.success.add(_elem14);
                  }
                  iprot.readListEnd();
                }
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PEX:
              if (field.type == TType.STRUCT) {
                this.pex = new PromotionException();
                this.pex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        {
          oprot.writeListBegin(new TList(TType.STRUCT, this.success.size()));
          for (Promotion _iter15 : this.success)
          {
            _iter15.write(oprot);
          }
          oprot.writeListEnd();
        }
        oprot.writeFieldEnd();
      } else if (this.isSetPex()) {
        oprot.writeFieldBegin(PEX_FIELD_DESC);
        this.pex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("pex:");
      if (this.pex == null) {
        sb.append("null");
      } else {
        sb.append(this.pex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField PROMOTION_ID_FIELD_DESC = new TField("promotionId", TType.I64, (short)1);

    private long promotionId;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PROMOTION_ID((short)1, "promotionId");

      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 __PROMOTIONID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PROMOTION_ID, new FieldMetaData("promotionId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
    }});

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

    public getPromotionById_args() {
    }

    public getPromotionById_args(
      long promotionId)
    {
      this();
      this.promotionId = promotionId;
      setPromotionIdIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPromotionById_args(getPromotionById_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.promotionId = other.promotionId;
    }

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

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

    public long getPromotionId() {
      return this.promotionId;
    }

    public getPromotionById_args setPromotionId(long promotionId) {
      this.promotionId = promotionId;
      setPromotionIdIsSet(true);
      return this;
    }

    public void unsetPromotionId() {
      __isset_bit_vector.clear(__PROMOTIONID_ISSET_ID);
    }

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

    public void setPromotionIdIsSet(boolean value) {
      __isset_bit_vector.set(__PROMOTIONID_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PROMOTION_ID:
        if (value == null) {
          unsetPromotionId();
        } else {
          setPromotionId((Long)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PROMOTION_ID:
        return new Long(getPromotionId());

      }
      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 PROMOTION_ID:
        return isSetPromotionId();
      }
      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 getPromotionById_args)
        return this.equals((getPromotionById_args)that);
      return false;
    }

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

      boolean this_present_promotionId = true;
      boolean that_present_promotionId = true;
      if (this_present_promotionId || that_present_promotionId) {
        if (!(this_present_promotionId && that_present_promotionId))
          return false;
        if (this.promotionId != that.promotionId)
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetPromotionId()).compareTo(isSetPromotionId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(promotionId, typedOther.promotionId);
      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 PROMOTION_ID:
              if (field.type == TType.I64) {
                this.promotionId = iprot.readI64();
                setPromotionIdIsSet(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(PROMOTION_ID_FIELD_DESC);
      oprot.writeI64(this.promotionId);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("promotionId:");
      sb.append(this.promotionId);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
    private static final TField PEX_FIELD_DESC = new TField("pex", TType.STRUCT, (short)1);

    private Promotion success;
    private PromotionException pex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PEX((short)1, "pex");

      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

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new StructMetaData(TType.STRUCT, Promotion.class)));
      put(_Fields.PEX, new FieldMetaData("pex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public getPromotionById_result() {
    }

    public getPromotionById_result(
      Promotion success,
      PromotionException pex)
    {
      this();
      this.success = success;
      this.pex = pex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getPromotionById_result(getPromotionById_result other) {
      if (other.isSetSuccess()) {
        this.success = new Promotion(other.success);
      }
      if (other.isSetPex()) {
        this.pex = new PromotionException(other.pex);
      }
    }

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

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

    public Promotion getSuccess() {
      return this.success;
    }

    public getPromotionById_result setSuccess(Promotion success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

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

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public PromotionException getPex() {
      return this.pex;
    }

    public getPromotionById_result setPex(PromotionException pex) {
      this.pex = pex;
      return this;
    }

    public void unsetPex() {
      this.pex = null;
    }

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

    public void setPexIsSet(boolean value) {
      if (!value) {
        this.pex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((Promotion)value);
        }
        break;

      case PEX:
        if (value == null) {
          unsetPex();
        } else {
          setPex((PromotionException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case PEX:
        return getPex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case PEX:
        return isSetPex();
      }
      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 getPromotionById_result)
        return this.equals((getPromotionById_result)that);
      return false;
    }

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

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_pex = true && this.isSetPex();
      boolean that_present_pex = true && that.isSetPex();
      if (this_present_pex || that_present_pex) {
        if (!(this_present_pex && that_present_pex))
          return false;
        if (!this.pex.equals(that.pex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetPex()).compareTo(isSetPex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pex, typedOther.pex);
      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 SUCCESS:
              if (field.type == TType.STRUCT) {
                this.success = new Promotion();
                this.success.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PEX:
              if (field.type == TType.STRUCT) {
                this.pex = new PromotionException();
                this.pex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        this.success.write(oprot);
        oprot.writeFieldEnd();
      } else if (this.isSetPex()) {
        oprot.writeFieldBegin(PEX_FIELD_DESC);
        this.pex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("pex:");
      if (this.pex == null) {
        sb.append("null");
      } else {
        sb.append(this.pex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField PROMOTION_ID_FIELD_DESC = new TField("promotionId", TType.I64, (short)1);
    private static final TField COUPON_CODE_FIELD_DESC = new TField("couponCode", TType.STRING, (short)2);

    private long promotionId;
    private String couponCode;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PROMOTION_ID((short)1, "promotionId"),
      COUPON_CODE((short)2, "couponCode");

      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 __PROMOTIONID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PROMOTION_ID, new FieldMetaData("promotionId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.COUPON_CODE, new FieldMetaData("couponCode", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
    }});

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

    public generateCouponsForPromotion_args() {
    }

    public generateCouponsForPromotion_args(
      long promotionId,
      String couponCode)
    {
      this();
      this.promotionId = promotionId;
      setPromotionIdIsSet(true);
      this.couponCode = couponCode;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public generateCouponsForPromotion_args(generateCouponsForPromotion_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.promotionId = other.promotionId;
      if (other.isSetCouponCode()) {
        this.couponCode = other.couponCode;
      }
    }

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

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

    public long getPromotionId() {
      return this.promotionId;
    }

    public generateCouponsForPromotion_args setPromotionId(long promotionId) {
      this.promotionId = promotionId;
      setPromotionIdIsSet(true);
      return this;
    }

    public void unsetPromotionId() {
      __isset_bit_vector.clear(__PROMOTIONID_ISSET_ID);
    }

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

    public void setPromotionIdIsSet(boolean value) {
      __isset_bit_vector.set(__PROMOTIONID_ISSET_ID, value);
    }

    public String getCouponCode() {
      return this.couponCode;
    }

    public generateCouponsForPromotion_args setCouponCode(String couponCode) {
      this.couponCode = couponCode;
      return this;
    }

    public void unsetCouponCode() {
      this.couponCode = null;
    }

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

    public void setCouponCodeIsSet(boolean value) {
      if (!value) {
        this.couponCode = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PROMOTION_ID:
        if (value == null) {
          unsetPromotionId();
        } else {
          setPromotionId((Long)value);
        }
        break;

      case COUPON_CODE:
        if (value == null) {
          unsetCouponCode();
        } else {
          setCouponCode((String)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PROMOTION_ID:
        return new Long(getPromotionId());

      case COUPON_CODE:
        return getCouponCode();

      }
      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 PROMOTION_ID:
        return isSetPromotionId();
      case COUPON_CODE:
        return isSetCouponCode();
      }
      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 generateCouponsForPromotion_args)
        return this.equals((generateCouponsForPromotion_args)that);
      return false;
    }

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

      boolean this_present_promotionId = true;
      boolean that_present_promotionId = true;
      if (this_present_promotionId || that_present_promotionId) {
        if (!(this_present_promotionId && that_present_promotionId))
          return false;
        if (this.promotionId != that.promotionId)
          return false;
      }

      boolean this_present_couponCode = true && this.isSetCouponCode();
      boolean that_present_couponCode = true && that.isSetCouponCode();
      if (this_present_couponCode || that_present_couponCode) {
        if (!(this_present_couponCode && that_present_couponCode))
          return false;
        if (!this.couponCode.equals(that.couponCode))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetPromotionId()).compareTo(isSetPromotionId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(promotionId, typedOther.promotionId);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetCouponCode()).compareTo(isSetCouponCode());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(couponCode, typedOther.couponCode);
      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 PROMOTION_ID:
              if (field.type == TType.I64) {
                this.promotionId = iprot.readI64();
                setPromotionIdIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case COUPON_CODE:
              if (field.type == TType.STRING) {
                this.couponCode = iprot.readString();
              } 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(PROMOTION_ID_FIELD_DESC);
      oprot.writeI64(this.promotionId);
      oprot.writeFieldEnd();
      if (this.couponCode != null) {
        oprot.writeFieldBegin(COUPON_CODE_FIELD_DESC);
        oprot.writeString(this.couponCode);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("promotionId:");
      sb.append(this.promotionId);
      first = false;
      if (!first) sb.append(", ");
      sb.append("couponCode:");
      if (this.couponCode == null) {
        sb.append("null");
      } else {
        sb.append(this.couponCode);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField PEX_FIELD_DESC = new TField("pex", TType.STRUCT, (short)1);

    private PromotionException pex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PEX((short)1, "pex");

      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

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PEX, new FieldMetaData("pex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public generateCouponsForPromotion_result() {
    }

    public generateCouponsForPromotion_result(
      PromotionException pex)
    {
      this();
      this.pex = pex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public generateCouponsForPromotion_result(generateCouponsForPromotion_result other) {
      if (other.isSetPex()) {
        this.pex = new PromotionException(other.pex);
      }
    }

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

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

    public PromotionException getPex() {
      return this.pex;
    }

    public generateCouponsForPromotion_result setPex(PromotionException pex) {
      this.pex = pex;
      return this;
    }

    public void unsetPex() {
      this.pex = null;
    }

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

    public void setPexIsSet(boolean value) {
      if (!value) {
        this.pex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PEX:
        if (value == null) {
          unsetPex();
        } else {
          setPex((PromotionException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PEX:
        return getPex();

      }
      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 PEX:
        return isSetPex();
      }
      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 generateCouponsForPromotion_result)
        return this.equals((generateCouponsForPromotion_result)that);
      return false;
    }

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

      boolean this_present_pex = true && this.isSetPex();
      boolean that_present_pex = true && that.isSetPex();
      if (this_present_pex || that_present_pex) {
        if (!(this_present_pex && that_present_pex))
          return false;
        if (!this.pex.equals(that.pex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetPex()).compareTo(isSetPex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pex, typedOther.pex);
      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 PEX:
              if (field.type == TType.STRUCT) {
                this.pex = new PromotionException();
                this.pex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetPex()) {
        oprot.writeFieldBegin(PEX_FIELD_DESC);
        this.pex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("pex:");
      if (this.pex == null) {
        sb.append("null");
      } else {
        sb.append(this.pex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField COUPON_CODE_FIELD_DESC = new TField("couponCode", TType.STRING, (short)1);
    private static final TField CART_ID_FIELD_DESC = new TField("cartId", TType.I64, (short)2);

    private String couponCode;
    private long cartId;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      COUPON_CODE((short)1, "couponCode"),
      CART_ID((short)2, "cartId");

      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 __CARTID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.COUPON_CODE, new FieldMetaData("couponCode", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
      put(_Fields.CART_ID, new FieldMetaData("cartId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
    }});

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

    public applyCoupon_args() {
    }

    public applyCoupon_args(
      String couponCode,
      long cartId)
    {
      this();
      this.couponCode = couponCode;
      this.cartId = cartId;
      setCartIdIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public applyCoupon_args(applyCoupon_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      if (other.isSetCouponCode()) {
        this.couponCode = other.couponCode;
      }
      this.cartId = other.cartId;
    }

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

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

    public String getCouponCode() {
      return this.couponCode;
    }

    public applyCoupon_args setCouponCode(String couponCode) {
      this.couponCode = couponCode;
      return this;
    }

    public void unsetCouponCode() {
      this.couponCode = null;
    }

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

    public void setCouponCodeIsSet(boolean value) {
      if (!value) {
        this.couponCode = null;
      }
    }

    public long getCartId() {
      return this.cartId;
    }

    public applyCoupon_args setCartId(long cartId) {
      this.cartId = cartId;
      setCartIdIsSet(true);
      return this;
    }

    public void unsetCartId() {
      __isset_bit_vector.clear(__CARTID_ISSET_ID);
    }

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

    public void setCartIdIsSet(boolean value) {
      __isset_bit_vector.set(__CARTID_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case COUPON_CODE:
        if (value == null) {
          unsetCouponCode();
        } else {
          setCouponCode((String)value);
        }
        break;

      case CART_ID:
        if (value == null) {
          unsetCartId();
        } else {
          setCartId((Long)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case COUPON_CODE:
        return getCouponCode();

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

      }
      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 COUPON_CODE:
        return isSetCouponCode();
      case CART_ID:
        return isSetCartId();
      }
      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 applyCoupon_args)
        return this.equals((applyCoupon_args)that);
      return false;
    }

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

      boolean this_present_couponCode = true && this.isSetCouponCode();
      boolean that_present_couponCode = true && that.isSetCouponCode();
      if (this_present_couponCode || that_present_couponCode) {
        if (!(this_present_couponCode && that_present_couponCode))
          return false;
        if (!this.couponCode.equals(that.couponCode))
          return false;
      }

      boolean this_present_cartId = true;
      boolean that_present_cartId = true;
      if (this_present_cartId || that_present_cartId) {
        if (!(this_present_cartId && that_present_cartId))
          return false;
        if (this.cartId != that.cartId)
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetCouponCode()).compareTo(isSetCouponCode());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(couponCode, typedOther.couponCode);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetCartId()).compareTo(isSetCartId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(cartId, typedOther.cartId);
      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 COUPON_CODE:
              if (field.type == TType.STRING) {
                this.couponCode = iprot.readString();
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case CART_ID:
              if (field.type == TType.I64) {
                this.cartId = iprot.readI64();
                setCartIdIsSet(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);
      if (this.couponCode != null) {
        oprot.writeFieldBegin(COUPON_CODE_FIELD_DESC);
        oprot.writeString(this.couponCode);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(CART_ID_FIELD_DESC);
      oprot.writeI64(this.cartId);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("couponCode:");
      if (this.couponCode == null) {
        sb.append("null");
      } else {
        sb.append(this.couponCode);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("cartId:");
      sb.append(this.cartId);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0);
    private static final TField PEX_FIELD_DESC = new TField("pex", TType.STRUCT, (short)1);

    private Cart success;
    private PromotionException pex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PEX((short)1, "pex");

      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

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new StructMetaData(TType.STRUCT, Cart.class)));
      put(_Fields.PEX, new FieldMetaData("pex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public applyCoupon_result() {
    }

    public applyCoupon_result(
      Cart success,
      PromotionException pex)
    {
      this();
      this.success = success;
      this.pex = pex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public applyCoupon_result(applyCoupon_result other) {
      if (other.isSetSuccess()) {
        this.success = new Cart(other.success);
      }
      if (other.isSetPex()) {
        this.pex = new PromotionException(other.pex);
      }
    }

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

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

    public Cart getSuccess() {
      return this.success;
    }

    public applyCoupon_result setSuccess(Cart success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

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

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public PromotionException getPex() {
      return this.pex;
    }

    public applyCoupon_result setPex(PromotionException pex) {
      this.pex = pex;
      return this;
    }

    public void unsetPex() {
      this.pex = null;
    }

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

    public void setPexIsSet(boolean value) {
      if (!value) {
        this.pex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((Cart)value);
        }
        break;

      case PEX:
        if (value == null) {
          unsetPex();
        } else {
          setPex((PromotionException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case PEX:
        return getPex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case PEX:
        return isSetPex();
      }
      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 applyCoupon_result)
        return this.equals((applyCoupon_result)that);
      return false;
    }

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

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_pex = true && this.isSetPex();
      boolean that_present_pex = true && that.isSetPex();
      if (this_present_pex || that_present_pex) {
        if (!(this_present_pex && that_present_pex))
          return false;
        if (!this.pex.equals(that.pex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetPex()).compareTo(isSetPex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pex, typedOther.pex);
      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 SUCCESS:
              if (field.type == TType.STRUCT) {
                this.success = new Cart();
                this.success.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PEX:
              if (field.type == TType.STRUCT) {
                this.pex = new PromotionException();
                this.pex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        this.success.write(oprot);
        oprot.writeFieldEnd();
      } else if (this.isSetPex()) {
        oprot.writeFieldBegin(PEX_FIELD_DESC);
        this.pex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("pex:");
      if (this.pex == null) {
        sb.append("null");
      } else {
        sb.append(this.pex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField COUPON_CODE_FIELD_DESC = new TField("couponCode", TType.STRING, (short)1);
    private static final TField TRANSACTION_ID_FIELD_DESC = new TField("transactionId", TType.I64, (short)2);
    private static final TField USER_ID_FIELD_DESC = new TField("userId", TType.I64, (short)3);

    private String couponCode;
    private long transactionId;
    private long userId;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      COUPON_CODE((short)1, "couponCode"),
      TRANSACTION_ID((short)2, "transactionId"),
      USER_ID((short)3, "userId");

      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 __TRANSACTIONID_ISSET_ID = 0;
    private static final int __USERID_ISSET_ID = 1;
    private BitSet __isset_bit_vector = new BitSet(2);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.COUPON_CODE, new FieldMetaData("couponCode", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
      put(_Fields.TRANSACTION_ID, new FieldMetaData("transactionId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.USER_ID, new FieldMetaData("userId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
    }});

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

    public trackCouponUsage_args() {
    }

    public trackCouponUsage_args(
      String couponCode,
      long transactionId,
      long userId)
    {
      this();
      this.couponCode = couponCode;
      this.transactionId = transactionId;
      setTransactionIdIsSet(true);
      this.userId = userId;
      setUserIdIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public trackCouponUsage_args(trackCouponUsage_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      if (other.isSetCouponCode()) {
        this.couponCode = other.couponCode;
      }
      this.transactionId = other.transactionId;
      this.userId = other.userId;
    }

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

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

    public String getCouponCode() {
      return this.couponCode;
    }

    public trackCouponUsage_args setCouponCode(String couponCode) {
      this.couponCode = couponCode;
      return this;
    }

    public void unsetCouponCode() {
      this.couponCode = null;
    }

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

    public void setCouponCodeIsSet(boolean value) {
      if (!value) {
        this.couponCode = null;
      }
    }

    public long getTransactionId() {
      return this.transactionId;
    }

    public trackCouponUsage_args setTransactionId(long transactionId) {
      this.transactionId = transactionId;
      setTransactionIdIsSet(true);
      return this;
    }

    public void unsetTransactionId() {
      __isset_bit_vector.clear(__TRANSACTIONID_ISSET_ID);
    }

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

    public void setTransactionIdIsSet(boolean value) {
      __isset_bit_vector.set(__TRANSACTIONID_ISSET_ID, value);
    }

    public long getUserId() {
      return this.userId;
    }

    public trackCouponUsage_args setUserId(long userId) {
      this.userId = userId;
      setUserIdIsSet(true);
      return this;
    }

    public void unsetUserId() {
      __isset_bit_vector.clear(__USERID_ISSET_ID);
    }

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

    public void setUserIdIsSet(boolean value) {
      __isset_bit_vector.set(__USERID_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case COUPON_CODE:
        if (value == null) {
          unsetCouponCode();
        } else {
          setCouponCode((String)value);
        }
        break;

      case TRANSACTION_ID:
        if (value == null) {
          unsetTransactionId();
        } else {
          setTransactionId((Long)value);
        }
        break;

      case USER_ID:
        if (value == null) {
          unsetUserId();
        } else {
          setUserId((Long)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case COUPON_CODE:
        return getCouponCode();

      case TRANSACTION_ID:
        return new Long(getTransactionId());

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

      }
      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 COUPON_CODE:
        return isSetCouponCode();
      case TRANSACTION_ID:
        return isSetTransactionId();
      case USER_ID:
        return isSetUserId();
      }
      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 trackCouponUsage_args)
        return this.equals((trackCouponUsage_args)that);
      return false;
    }

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

      boolean this_present_couponCode = true && this.isSetCouponCode();
      boolean that_present_couponCode = true && that.isSetCouponCode();
      if (this_present_couponCode || that_present_couponCode) {
        if (!(this_present_couponCode && that_present_couponCode))
          return false;
        if (!this.couponCode.equals(that.couponCode))
          return false;
      }

      boolean this_present_transactionId = true;
      boolean that_present_transactionId = true;
      if (this_present_transactionId || that_present_transactionId) {
        if (!(this_present_transactionId && that_present_transactionId))
          return false;
        if (this.transactionId != that.transactionId)
          return false;
      }

      boolean this_present_userId = true;
      boolean that_present_userId = true;
      if (this_present_userId || that_present_userId) {
        if (!(this_present_userId && that_present_userId))
          return false;
        if (this.userId != that.userId)
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetCouponCode()).compareTo(isSetCouponCode());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(couponCode, typedOther.couponCode);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetTransactionId()).compareTo(isSetTransactionId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(transactionId, typedOther.transactionId);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetUserId()).compareTo(isSetUserId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(userId, typedOther.userId);
      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 COUPON_CODE:
              if (field.type == TType.STRING) {
                this.couponCode = iprot.readString();
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case TRANSACTION_ID:
              if (field.type == TType.I64) {
                this.transactionId = iprot.readI64();
                setTransactionIdIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case USER_ID:
              if (field.type == TType.I64) {
                this.userId = iprot.readI64();
                setUserIdIsSet(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);
      if (this.couponCode != null) {
        oprot.writeFieldBegin(COUPON_CODE_FIELD_DESC);
        oprot.writeString(this.couponCode);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(TRANSACTION_ID_FIELD_DESC);
      oprot.writeI64(this.transactionId);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(USER_ID_FIELD_DESC);
      oprot.writeI64(this.userId);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("couponCode:");
      if (this.couponCode == null) {
        sb.append("null");
      } else {
        sb.append(this.couponCode);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("transactionId:");
      sb.append(this.transactionId);
      first = false;
      if (!first) sb.append(", ");
      sb.append("userId:");
      sb.append(this.userId);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField PEX_FIELD_DESC = new TField("pex", TType.STRUCT, (short)1);

    private PromotionException pex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      PEX((short)1, "pex");

      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

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.PEX, new FieldMetaData("pex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public trackCouponUsage_result() {
    }

    public trackCouponUsage_result(
      PromotionException pex)
    {
      this();
      this.pex = pex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public trackCouponUsage_result(trackCouponUsage_result other) {
      if (other.isSetPex()) {
        this.pex = new PromotionException(other.pex);
      }
    }

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

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

    public PromotionException getPex() {
      return this.pex;
    }

    public trackCouponUsage_result setPex(PromotionException pex) {
      this.pex = pex;
      return this;
    }

    public void unsetPex() {
      this.pex = null;
    }

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

    public void setPexIsSet(boolean value) {
      if (!value) {
        this.pex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case PEX:
        if (value == null) {
          unsetPex();
        } else {
          setPex((PromotionException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case PEX:
        return getPex();

      }
      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 PEX:
        return isSetPex();
      }
      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 trackCouponUsage_result)
        return this.equals((trackCouponUsage_result)that);
      return false;
    }

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

      boolean this_present_pex = true && this.isSetPex();
      boolean that_present_pex = true && that.isSetPex();
      if (this_present_pex || that_present_pex) {
        if (!(this_present_pex && that_present_pex))
          return false;
        if (!this.pex.equals(that.pex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetPex()).compareTo(isSetPex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pex, typedOther.pex);
      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 PEX:
              if (field.type == TType.STRUCT) {
                this.pex = new PromotionException();
                this.pex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetPex()) {
        oprot.writeFieldBegin(PEX_FIELD_DESC);
        this.pex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("pex:");
      if (this.pex == null) {
        sb.append("null");
      } else {
        sb.append(this.pex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField COUPON_CODE_FIELD_DESC = new TField("couponCode", TType.STRING, (short)1);
    private static final TField USER_ID_FIELD_DESC = new TField("userId", TType.I64, (short)2);

    private String couponCode;
    private long userId;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      COUPON_CODE((short)1, "couponCode"),
      USER_ID((short)2, "userId");

      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 __USERID_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.COUPON_CODE, new FieldMetaData("couponCode", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRING)));
      put(_Fields.USER_ID, new FieldMetaData("userId", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
    }});

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

    public getCouponUsageCountByUser_args() {
    }

    public getCouponUsageCountByUser_args(
      String couponCode,
      long userId)
    {
      this();
      this.couponCode = couponCode;
      this.userId = userId;
      setUserIdIsSet(true);
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getCouponUsageCountByUser_args(getCouponUsageCountByUser_args other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      if (other.isSetCouponCode()) {
        this.couponCode = other.couponCode;
      }
      this.userId = other.userId;
    }

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

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

    public String getCouponCode() {
      return this.couponCode;
    }

    public getCouponUsageCountByUser_args setCouponCode(String couponCode) {
      this.couponCode = couponCode;
      return this;
    }

    public void unsetCouponCode() {
      this.couponCode = null;
    }

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

    public void setCouponCodeIsSet(boolean value) {
      if (!value) {
        this.couponCode = null;
      }
    }

    public long getUserId() {
      return this.userId;
    }

    public getCouponUsageCountByUser_args setUserId(long userId) {
      this.userId = userId;
      setUserIdIsSet(true);
      return this;
    }

    public void unsetUserId() {
      __isset_bit_vector.clear(__USERID_ISSET_ID);
    }

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

    public void setUserIdIsSet(boolean value) {
      __isset_bit_vector.set(__USERID_ISSET_ID, value);
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case COUPON_CODE:
        if (value == null) {
          unsetCouponCode();
        } else {
          setCouponCode((String)value);
        }
        break;

      case USER_ID:
        if (value == null) {
          unsetUserId();
        } else {
          setUserId((Long)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case COUPON_CODE:
        return getCouponCode();

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

      }
      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 COUPON_CODE:
        return isSetCouponCode();
      case USER_ID:
        return isSetUserId();
      }
      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 getCouponUsageCountByUser_args)
        return this.equals((getCouponUsageCountByUser_args)that);
      return false;
    }

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

      boolean this_present_couponCode = true && this.isSetCouponCode();
      boolean that_present_couponCode = true && that.isSetCouponCode();
      if (this_present_couponCode || that_present_couponCode) {
        if (!(this_present_couponCode && that_present_couponCode))
          return false;
        if (!this.couponCode.equals(that.couponCode))
          return false;
      }

      boolean this_present_userId = true;
      boolean that_present_userId = true;
      if (this_present_userId || that_present_userId) {
        if (!(this_present_userId && that_present_userId))
          return false;
        if (this.userId != that.userId)
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetCouponCode()).compareTo(isSetCouponCode());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(couponCode, typedOther.couponCode);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetUserId()).compareTo(isSetUserId());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(userId, typedOther.userId);
      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 COUPON_CODE:
              if (field.type == TType.STRING) {
                this.couponCode = iprot.readString();
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case USER_ID:
              if (field.type == TType.I64) {
                this.userId = iprot.readI64();
                setUserIdIsSet(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);
      if (this.couponCode != null) {
        oprot.writeFieldBegin(COUPON_CODE_FIELD_DESC);
        oprot.writeString(this.couponCode);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldBegin(USER_ID_FIELD_DESC);
      oprot.writeI64(this.userId);
      oprot.writeFieldEnd();
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("couponCode:");
      if (this.couponCode == null) {
        sb.append("null");
      } else {
        sb.append(this.couponCode);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("userId:");
      sb.append(this.userId);
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

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

    private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.I64, (short)0);
    private static final TField PEX_FIELD_DESC = new TField("pex", TType.STRUCT, (short)1);

    private long success;
    private PromotionException pex;

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    public enum _Fields implements TFieldIdEnum {
      SUCCESS((short)0, "success"),
      PEX((short)1, "pex");

      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 __SUCCESS_ISSET_ID = 0;
    private BitSet __isset_bit_vector = new BitSet(1);

    public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
      put(_Fields.SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.I64)));
      put(_Fields.PEX, new FieldMetaData("pex", TFieldRequirementType.DEFAULT, 
          new FieldValueMetaData(TType.STRUCT)));
    }});

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

    public getCouponUsageCountByUser_result() {
    }

    public getCouponUsageCountByUser_result(
      long success,
      PromotionException pex)
    {
      this();
      this.success = success;
      setSuccessIsSet(true);
      this.pex = pex;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getCouponUsageCountByUser_result(getCouponUsageCountByUser_result other) {
      __isset_bit_vector.clear();
      __isset_bit_vector.or(other.__isset_bit_vector);
      this.success = other.success;
      if (other.isSetPex()) {
        this.pex = new PromotionException(other.pex);
      }
    }

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

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

    public long getSuccess() {
      return this.success;
    }

    public getCouponUsageCountByUser_result setSuccess(long success) {
      this.success = success;
      setSuccessIsSet(true);
      return this;
    }

    public void unsetSuccess() {
      __isset_bit_vector.clear(__SUCCESS_ISSET_ID);
    }

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

    public void setSuccessIsSet(boolean value) {
      __isset_bit_vector.set(__SUCCESS_ISSET_ID, value);
    }

    public PromotionException getPex() {
      return this.pex;
    }

    public getCouponUsageCountByUser_result setPex(PromotionException pex) {
      this.pex = pex;
      return this;
    }

    public void unsetPex() {
      this.pex = null;
    }

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

    public void setPexIsSet(boolean value) {
      if (!value) {
        this.pex = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((Long)value);
        }
        break;

      case PEX:
        if (value == null) {
          unsetPex();
        } else {
          setPex((PromotionException)value);
        }
        break;

      }
    }

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

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return new Long(getSuccess());

      case PEX:
        return getPex();

      }
      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 SUCCESS:
        return isSetSuccess();
      case PEX:
        return isSetPex();
      }
      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 getCouponUsageCountByUser_result)
        return this.equals((getCouponUsageCountByUser_result)that);
      return false;
    }

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

      boolean this_present_success = true;
      boolean that_present_success = true;
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (this.success != that.success)
          return false;
      }

      boolean this_present_pex = true && this.isSetPex();
      boolean that_present_pex = true && that.isSetPex();
      if (this_present_pex || that_present_pex) {
        if (!(this_present_pex && that_present_pex))
          return false;
        if (!this.pex.equals(that.pex))
          return false;
      }

      return true;
    }

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

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

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

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(success, typedOther.success);
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = Boolean.valueOf(isSetPex()).compareTo(isSetPex());
      if (lastComparison != 0) {
        return lastComparison;
      }
      lastComparison = TBaseHelper.compareTo(pex, typedOther.pex);
      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 SUCCESS:
              if (field.type == TType.I64) {
                this.success = iprot.readI64();
                setSuccessIsSet(true);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
            case PEX:
              if (field.type == TType.STRUCT) {
                this.pex = new PromotionException();
                this.pex.read(iprot);
              } else { 
                TProtocolUtil.skip(iprot, field.type);
              }
              break;
          }
          iprot.readFieldEnd();
        }
      }
      iprot.readStructEnd();
      validate();
    }

    public void write(TProtocol oprot) throws TException {
      oprot.writeStructBegin(STRUCT_DESC);

      if (this.isSetSuccess()) {
        oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
        oprot.writeI64(this.success);
        oprot.writeFieldEnd();
      } else if (this.isSetPex()) {
        oprot.writeFieldBegin(PEX_FIELD_DESC);
        this.pex.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

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

      sb.append("success:");
      sb.append(this.success);
      first = false;
      if (!first) sb.append(", ");
      sb.append("pex:");
      if (this.pex == null) {
        sb.append("null");
      } else {
        sb.append(this.pex);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

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

  }

}