Subversion Repositories SmartDukaan

Rev

Blame | 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.order;

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

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

  private static final org.apache.thrift.protocol.TField NEW_COUPON_CREATED_FIELD_DESC = new org.apache.thrift.protocol.TField("newCouponCreated", org.apache.thrift.protocol.TType.STRUCT, (short)1);
  private static final org.apache.thrift.protocol.TField IS_SUCCESSFUL_FIELD_DESC = new org.apache.thrift.protocol.TField("isSuccessful", org.apache.thrift.protocol.TType.BOOL, (short)2);
  private static final org.apache.thrift.protocol.TField ERROR_MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("errorMessage", org.apache.thrift.protocol.TType.STRING, (short)3);
  private static final org.apache.thrift.protocol.TField INVALID_COUPONS_FIELD_DESC = new org.apache.thrift.protocol.TField("invalidCoupons", org.apache.thrift.protocol.TType.LIST, (short)4);

  private RechargeCoupon newCouponCreated; // required
  private boolean isSuccessful; // required
  private String errorMessage; // required
  private List<RechargeCoupon> invalidCoupons; // 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 {
    NEW_COUPON_CREATED((short)1, "newCouponCreated"),
    IS_SUCCESSFUL((short)2, "isSuccessful"),
    ERROR_MESSAGE((short)3, "errorMessage"),
    INVALID_COUPONS((short)4, "invalidCoupons");

    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: // NEW_COUPON_CREATED
          return NEW_COUPON_CREATED;
        case 2: // IS_SUCCESSFUL
          return IS_SUCCESSFUL;
        case 3: // ERROR_MESSAGE
          return ERROR_MESSAGE;
        case 4: // INVALID_COUPONS
          return INVALID_COUPONS;
        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
  private static final int __ISSUCCESSFUL_ISSET_ID = 0;
  private BitSet __isset_bit_vector = new BitSet(1);

  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.NEW_COUPON_CREATED, new org.apache.thrift.meta_data.FieldMetaData("newCouponCreated", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, RechargeCoupon.class)));
    tmpMap.put(_Fields.IS_SUCCESSFUL, new org.apache.thrift.meta_data.FieldMetaData("isSuccessful", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
    tmpMap.put(_Fields.ERROR_MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("errorMessage", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
    tmpMap.put(_Fields.INVALID_COUPONS, new org.apache.thrift.meta_data.FieldMetaData("invalidCoupons", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, 
            new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, RechargeCoupon.class))));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(RechargeResponse.class, metaDataMap);
  }

  public RechargeResponse() {
  }

  public RechargeResponse(
    RechargeCoupon newCouponCreated,
    boolean isSuccessful,
    String errorMessage,
    List<RechargeCoupon> invalidCoupons)
  {
    this();
    this.newCouponCreated = newCouponCreated;
    this.isSuccessful = isSuccessful;
    setIsSuccessfulIsSet(true);
    this.errorMessage = errorMessage;
    this.invalidCoupons = invalidCoupons;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public RechargeResponse(RechargeResponse other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetNewCouponCreated()) {
      this.newCouponCreated = new RechargeCoupon(other.newCouponCreated);
    }
    this.isSuccessful = other.isSuccessful;
    if (other.isSetErrorMessage()) {
      this.errorMessage = other.errorMessage;
    }
    if (other.isSetInvalidCoupons()) {
      List<RechargeCoupon> __this__invalidCoupons = new ArrayList<RechargeCoupon>();
      for (RechargeCoupon other_element : other.invalidCoupons) {
        __this__invalidCoupons.add(new RechargeCoupon(other_element));
      }
      this.invalidCoupons = __this__invalidCoupons;
    }
  }

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

  @Override
  public void clear() {
    this.newCouponCreated = null;
    setIsSuccessfulIsSet(false);
    this.isSuccessful = false;
    this.errorMessage = null;
    this.invalidCoupons = null;
  }

  public RechargeCoupon getNewCouponCreated() {
    return this.newCouponCreated;
  }

  public void setNewCouponCreated(RechargeCoupon newCouponCreated) {
    this.newCouponCreated = newCouponCreated;
  }

  public void unsetNewCouponCreated() {
    this.newCouponCreated = null;
  }

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

  public void setNewCouponCreatedIsSet(boolean value) {
    if (!value) {
      this.newCouponCreated = null;
    }
  }

  public boolean isIsSuccessful() {
    return this.isSuccessful;
  }

  public void setIsSuccessful(boolean isSuccessful) {
    this.isSuccessful = isSuccessful;
    setIsSuccessfulIsSet(true);
  }

  public void unsetIsSuccessful() {
    __isset_bit_vector.clear(__ISSUCCESSFUL_ISSET_ID);
  }

  /** Returns true if field isSuccessful is set (has been assigned a value) and false otherwise */
  public boolean isSetIsSuccessful() {
    return __isset_bit_vector.get(__ISSUCCESSFUL_ISSET_ID);
  }

  public void setIsSuccessfulIsSet(boolean value) {
    __isset_bit_vector.set(__ISSUCCESSFUL_ISSET_ID, value);
  }

  public String getErrorMessage() {
    return this.errorMessage;
  }

  public void setErrorMessage(String errorMessage) {
    this.errorMessage = errorMessage;
  }

  public void unsetErrorMessage() {
    this.errorMessage = null;
  }

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

  public void setErrorMessageIsSet(boolean value) {
    if (!value) {
      this.errorMessage = null;
    }
  }

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

  public java.util.Iterator<RechargeCoupon> getInvalidCouponsIterator() {
    return (this.invalidCoupons == null) ? null : this.invalidCoupons.iterator();
  }

  public void addToInvalidCoupons(RechargeCoupon elem) {
    if (this.invalidCoupons == null) {
      this.invalidCoupons = new ArrayList<RechargeCoupon>();
    }
    this.invalidCoupons.add(elem);
  }

  public List<RechargeCoupon> getInvalidCoupons() {
    return this.invalidCoupons;
  }

  public void setInvalidCoupons(List<RechargeCoupon> invalidCoupons) {
    this.invalidCoupons = invalidCoupons;
  }

  public void unsetInvalidCoupons() {
    this.invalidCoupons = null;
  }

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

  public void setInvalidCouponsIsSet(boolean value) {
    if (!value) {
      this.invalidCoupons = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case NEW_COUPON_CREATED:
      if (value == null) {
        unsetNewCouponCreated();
      } else {
        setNewCouponCreated((RechargeCoupon)value);
      }
      break;

    case IS_SUCCESSFUL:
      if (value == null) {
        unsetIsSuccessful();
      } else {
        setIsSuccessful((Boolean)value);
      }
      break;

    case ERROR_MESSAGE:
      if (value == null) {
        unsetErrorMessage();
      } else {
        setErrorMessage((String)value);
      }
      break;

    case INVALID_COUPONS:
      if (value == null) {
        unsetInvalidCoupons();
      } else {
        setInvalidCoupons((List<RechargeCoupon>)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case NEW_COUPON_CREATED:
      return getNewCouponCreated();

    case IS_SUCCESSFUL:
      return Boolean.valueOf(isIsSuccessful());

    case ERROR_MESSAGE:
      return getErrorMessage();

    case INVALID_COUPONS:
      return getInvalidCoupons();

    }
    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 NEW_COUPON_CREATED:
      return isSetNewCouponCreated();
    case IS_SUCCESSFUL:
      return isSetIsSuccessful();
    case ERROR_MESSAGE:
      return isSetErrorMessage();
    case INVALID_COUPONS:
      return isSetInvalidCoupons();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_newCouponCreated = true && this.isSetNewCouponCreated();
    boolean that_present_newCouponCreated = true && that.isSetNewCouponCreated();
    if (this_present_newCouponCreated || that_present_newCouponCreated) {
      if (!(this_present_newCouponCreated && that_present_newCouponCreated))
        return false;
      if (!this.newCouponCreated.equals(that.newCouponCreated))
        return false;
    }

    boolean this_present_isSuccessful = true;
    boolean that_present_isSuccessful = true;
    if (this_present_isSuccessful || that_present_isSuccessful) {
      if (!(this_present_isSuccessful && that_present_isSuccessful))
        return false;
      if (this.isSuccessful != that.isSuccessful)
        return false;
    }

    boolean this_present_errorMessage = true && this.isSetErrorMessage();
    boolean that_present_errorMessage = true && that.isSetErrorMessage();
    if (this_present_errorMessage || that_present_errorMessage) {
      if (!(this_present_errorMessage && that_present_errorMessage))
        return false;
      if (!this.errorMessage.equals(that.errorMessage))
        return false;
    }

    boolean this_present_invalidCoupons = true && this.isSetInvalidCoupons();
    boolean that_present_invalidCoupons = true && that.isSetInvalidCoupons();
    if (this_present_invalidCoupons || that_present_invalidCoupons) {
      if (!(this_present_invalidCoupons && that_present_invalidCoupons))
        return false;
      if (!this.invalidCoupons.equals(that.invalidCoupons))
        return false;
    }

    return true;
  }

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

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

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

    lastComparison = Boolean.valueOf(isSetNewCouponCreated()).compareTo(typedOther.isSetNewCouponCreated());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNewCouponCreated()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.newCouponCreated, typedOther.newCouponCreated);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetIsSuccessful()).compareTo(typedOther.isSetIsSuccessful());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetIsSuccessful()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.isSuccessful, typedOther.isSuccessful);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetErrorMessage()).compareTo(typedOther.isSetErrorMessage());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetErrorMessage()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.errorMessage, typedOther.errorMessage);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetInvalidCoupons()).compareTo(typedOther.isSetInvalidCoupons());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetInvalidCoupons()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.invalidCoupons, typedOther.invalidCoupons);
      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: // NEW_COUPON_CREATED
          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
            this.newCouponCreated = new RechargeCoupon();
            this.newCouponCreated.read(iprot);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // IS_SUCCESSFUL
          if (field.type == org.apache.thrift.protocol.TType.BOOL) {
            this.isSuccessful = iprot.readBool();
            setIsSuccessfulIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // ERROR_MESSAGE
          if (field.type == org.apache.thrift.protocol.TType.STRING) {
            this.errorMessage = iprot.readString();
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // INVALID_COUPONS
          if (field.type == org.apache.thrift.protocol.TType.LIST) {
            {
              org.apache.thrift.protocol.TList _list8 = iprot.readListBegin();
              this.invalidCoupons = new ArrayList<RechargeCoupon>(_list8.size);
              for (int _i9 = 0; _i9 < _list8.size; ++_i9)
              {
                RechargeCoupon _elem10; // required
                _elem10 = new RechargeCoupon();
                _elem10.read(iprot);
                this.invalidCoupons.add(_elem10);
              }
              iprot.readListEnd();
            }
          } 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.newCouponCreated != null) {
      oprot.writeFieldBegin(NEW_COUPON_CREATED_FIELD_DESC);
      this.newCouponCreated.write(oprot);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(IS_SUCCESSFUL_FIELD_DESC);
    oprot.writeBool(this.isSuccessful);
    oprot.writeFieldEnd();
    if (this.errorMessage != null) {
      oprot.writeFieldBegin(ERROR_MESSAGE_FIELD_DESC);
      oprot.writeString(this.errorMessage);
      oprot.writeFieldEnd();
    }
    if (this.invalidCoupons != null) {
      oprot.writeFieldBegin(INVALID_COUPONS_FIELD_DESC);
      {
        oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.invalidCoupons.size()));
        for (RechargeCoupon _iter11 : this.invalidCoupons)
        {
          _iter11.write(oprot);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("newCouponCreated:");
    if (this.newCouponCreated == null) {
      sb.append("null");
    } else {
      sb.append(this.newCouponCreated);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("isSuccessful:");
    sb.append(this.isSuccessful);
    first = false;
    if (!first) sb.append(", ");
    sb.append("errorMessage:");
    if (this.errorMessage == null) {
      sb.append("null");
    } else {
      sb.append(this.errorMessage);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("invalidCoupons:");
    if (this.invalidCoupons == null) {
      sb.append("null");
    } else {
      sb.append(this.invalidCoupons);
    }
    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 {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bit_vector = new BitSet(1);
      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);
    }
  }

}