Subversion Repositories SmartDukaan

Rev

Rev 3430 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * Autogenerated by Thrift Compiler (0.7.0)
 *
 * 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.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Coupon implements org.apache.thrift.TBase<Coupon, Coupon._Fields>, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Coupon");

  private static final org.apache.thrift.protocol.TField COUPON_CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("couponCode", org.apache.thrift.protocol.TType.STRING, (short)1);
  private static final org.apache.thrift.protocol.TField PROMOTION_FIELD_DESC = new org.apache.thrift.protocol.TField("promotion", org.apache.thrift.protocol.TType.STRUCT, (short)2);
  private static final org.apache.thrift.protocol.TField ARGUMENTS_FIELD_DESC = new org.apache.thrift.protocol.TField("arguments", org.apache.thrift.protocol.TType.STRING, (short)3);
  private static final org.apache.thrift.protocol.TField COUPON_CATEGORY_FIELD_DESC = new org.apache.thrift.protocol.TField("coupon_category", org.apache.thrift.protocol.TType.I32, (short)4);

  private String couponCode; // required
  private Promotion promotion; // required
  private String arguments; // required
  private CouponCategory coupon_category; // required

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    COUPON_CODE((short)1, "couponCode"),
    PROMOTION((short)2, "promotion"),
    ARGUMENTS((short)3, "arguments"),
    /**
     * 
     * @see CouponCategory
     */
    COUPON_CATEGORY((short)4, "coupon_category");

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

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

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // COUPON_CODE
          return COUPON_CODE;
        case 2: // PROMOTION
          return PROMOTION;
        case 3: // ARGUMENTS
          return ARGUMENTS;
        case 4: // COUPON_CATEGORY
          return COUPON_CATEGORY;
        default:
          return null;
      }
    }

    /**
     * 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, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.COUPON_CODE, new org.apache.thrift.meta_data.FieldMetaData("couponCode", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.PROMOTION, new org.apache.thrift.meta_data.FieldMetaData("promotion", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, Promotion.class)));
    tmpMap.put(_Fields.ARGUMENTS, new org.apache.thrift.meta_data.FieldMetaData("arguments", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.COUPON_CATEGORY, new org.apache.thrift.meta_data.FieldMetaData("coupon_category", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, CouponCategory.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Coupon.class, metaDataMap);
  }

  public Coupon() {
  }

  public Coupon(
    String couponCode,
    Promotion promotion,
    String arguments,
    CouponCategory coupon_category)
  {
    this();
    this.couponCode = couponCode;
    this.promotion = promotion;
    this.arguments = arguments;
    this.coupon_category = coupon_category;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Coupon(Coupon other) {
    if (other.isSetCouponCode()) {
      this.couponCode = other.couponCode;
    }
    if (other.isSetPromotion()) {
      this.promotion = new Promotion(other.promotion);
    }
    if (other.isSetArguments()) {
      this.arguments = other.arguments;
    }
    if (other.isSetCoupon_category()) {
      this.coupon_category = other.coupon_category;
    }
  }

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

  @Override
  public void clear() {
    this.couponCode = null;
    this.promotion = null;
    this.arguments = null;
    this.coupon_category = null;
  }

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

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

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

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

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

  public Promotion getPromotion() {
    return this.promotion;
  }

  public void setPromotion(Promotion promotion) {
    this.promotion = promotion;
  }

  public void unsetPromotion() {
    this.promotion = null;
  }

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

  public void setPromotionIsSet(boolean value) {
    if (!value) {
      this.promotion = null;
    }
  }

  public String getArguments() {
    return this.arguments;
  }

  public void setArguments(String arguments) {
    this.arguments = arguments;
  }

  public void unsetArguments() {
    this.arguments = null;
  }

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

  public void setArgumentsIsSet(boolean value) {
    if (!value) {
      this.arguments = null;
    }
  }

  /**
   * 
   * @see CouponCategory
   */
  public CouponCategory getCoupon_category() {
    return this.coupon_category;
  }

  /**
   * 
   * @see CouponCategory
   */
  public void setCoupon_category(CouponCategory coupon_category) {
    this.coupon_category = coupon_category;
  }

  public void unsetCoupon_category() {
    this.coupon_category = null;
  }

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

  public void setCoupon_categoryIsSet(boolean value) {
    if (!value) {
      this.coupon_category = null;
    }
  }

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

    case PROMOTION:
      if (value == null) {
        unsetPromotion();
      } else {
        setPromotion((Promotion)value);
      }
      break;

    case ARGUMENTS:
      if (value == null) {
        unsetArguments();
      } else {
        setArguments((String)value);
      }
      break;

    case COUPON_CATEGORY:
      if (value == null) {
        unsetCoupon_category();
      } else {
        setCoupon_category((CouponCategory)value);
      }
      break;

    }
  }

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

    case PROMOTION:
      return getPromotion();

    case ARGUMENTS:
      return getArguments();

    case COUPON_CATEGORY:
      return getCoupon_category();

    }
    throw new IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case COUPON_CODE:
      return isSetCouponCode();
    case PROMOTION:
      return isSetPromotion();
    case ARGUMENTS:
      return isSetArguments();
    case COUPON_CATEGORY:
      return isSetCoupon_category();
    }
    throw new IllegalStateException();
  }

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

  public boolean equals(Coupon 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_promotion = true && this.isSetPromotion();
    boolean that_present_promotion = true && that.isSetPromotion();
    if (this_present_promotion || that_present_promotion) {
      if (!(this_present_promotion && that_present_promotion))
        return false;
      if (!this.promotion.equals(that.promotion))
        return false;
    }

    boolean this_present_arguments = true && this.isSetArguments();
    boolean that_present_arguments = true && that.isSetArguments();
    if (this_present_arguments || that_present_arguments) {
      if (!(this_present_arguments && that_present_arguments))
        return false;
      if (!this.arguments.equals(that.arguments))
        return false;
    }

    boolean this_present_coupon_category = true && this.isSetCoupon_category();
    boolean that_present_coupon_category = true && that.isSetCoupon_category();
    if (this_present_coupon_category || that_present_coupon_category) {
      if (!(this_present_coupon_category && that_present_coupon_category))
        return false;
      if (!this.coupon_category.equals(that.coupon_category))
        return false;
    }

    return true;
  }

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

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

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

    lastComparison = Boolean.valueOf(isSetCouponCode()).compareTo(typedOther.isSetCouponCode());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCouponCode()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.couponCode, typedOther.couponCode);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPromotion()).compareTo(typedOther.isSetPromotion());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPromotion()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.promotion, typedOther.promotion);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetArguments()).compareTo(typedOther.isSetArguments());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetArguments()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.arguments, typedOther.arguments);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetCoupon_category()).compareTo(typedOther.isSetCoupon_category());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCoupon_category()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.coupon_category, typedOther.coupon_category);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    org.apache.thrift.protocol.TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
        break;
      }
      switch (field.id) {
        case 1: // COUPON_CODE
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
            this.couponCode = iprot.readString();
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // PROMOTION
          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
            this.promotion = new Promotion();
            this.promotion.read(iprot);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // ARGUMENTS
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
            this.arguments = iprot.readString();
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // COUPON_CATEGORY
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.coupon_category = CouponCategory.findByValue(iprot.readI32());
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        default:
          org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();
    validate();
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.couponCode != null) {
      oprot.writeFieldBegin(COUPON_CODE_FIELD_DESC);
      oprot.writeString(this.couponCode);
      oprot.writeFieldEnd();
    }
    if (this.promotion != null) {
      oprot.writeFieldBegin(PROMOTION_FIELD_DESC);
      this.promotion.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.arguments != null) {
      oprot.writeFieldBegin(ARGUMENTS_FIELD_DESC);
      oprot.writeString(this.arguments);
      oprot.writeFieldEnd();
    }
    if (this.coupon_category != null) {
      oprot.writeFieldBegin(COUPON_CATEGORY_FIELD_DESC);
      oprot.writeI32(this.coupon_category.getValue());
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("Coupon(");
    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("promotion:");
    if (this.promotion == null) {
      sb.append("null");
    } else {
      sb.append(this.promotion);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("arguments:");
    if (this.arguments == null) {
      sb.append("null");
    } else {
      sb.append(this.arguments);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("coupon_category:");
    if (this.coupon_category == null) {
      sb.append("null");
    } else {
      sb.append(this.coupon_category);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
    try {
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

}