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.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 Discount implements org.apache.thrift.TBase<Discount, Discount._Fields>, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Discount");

  private static final org.apache.thrift.protocol.TField CART_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("cart_id", org.apache.thrift.protocol.TType.I64, (short)1);
  private static final org.apache.thrift.protocol.TField ITEM_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("item_id", org.apache.thrift.protocol.TType.I64, (short)2);
  private static final org.apache.thrift.protocol.TField DISCOUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("discount", org.apache.thrift.protocol.TType.DOUBLE, (short)3);
  private static final org.apache.thrift.protocol.TField QUANTITY_FIELD_DESC = new org.apache.thrift.protocol.TField("quantity", org.apache.thrift.protocol.TType.DOUBLE, (short)4);

  private long cart_id; // required
  private long item_id; // required
  private double discount; // required
  private double quantity; // 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 {
    CART_ID((short)1, "cart_id"),
    ITEM_ID((short)2, "item_id"),
    DISCOUNT((short)3, "discount"),
    QUANTITY((short)4, "quantity");

    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: // CART_ID
          return CART_ID;
        case 2: // ITEM_ID
          return ITEM_ID;
        case 3: // DISCOUNT
          return DISCOUNT;
        case 4: // QUANTITY
          return QUANTITY;
        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 __CART_ID_ISSET_ID = 0;
  private static final int __ITEM_ID_ISSET_ID = 1;
  private static final int __DISCOUNT_ISSET_ID = 2;
  private static final int __QUANTITY_ISSET_ID = 3;
  private BitSet __isset_bit_vector = new BitSet(4);

  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.CART_ID, new org.apache.thrift.meta_data.FieldMetaData("cart_id", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.ITEM_ID, new org.apache.thrift.meta_data.FieldMetaData("item_id", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.DISCOUNT, new org.apache.thrift.meta_data.FieldMetaData("discount", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
    tmpMap.put(_Fields.QUANTITY, new org.apache.thrift.meta_data.FieldMetaData("quantity", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(Discount.class, metaDataMap);
  }

  public Discount() {
  }

  public Discount(
    long cart_id,
    long item_id,
    double discount,
    double quantity)
  {
    this();
    this.cart_id = cart_id;
    setCart_idIsSet(true);
    this.item_id = item_id;
    setItem_idIsSet(true);
    this.discount = discount;
    setDiscountIsSet(true);
    this.quantity = quantity;
    setQuantityIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Discount(Discount other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.cart_id = other.cart_id;
    this.item_id = other.item_id;
    this.discount = other.discount;
    this.quantity = other.quantity;
  }

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

  @Override
  public void clear() {
    setCart_idIsSet(false);
    this.cart_id = 0;
    setItem_idIsSet(false);
    this.item_id = 0;
    setDiscountIsSet(false);
    this.discount = 0.0;
    setQuantityIsSet(false);
    this.quantity = 0.0;
  }

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

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

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

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

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

  public long getItem_id() {
    return this.item_id;
  }

  public void setItem_id(long item_id) {
    this.item_id = item_id;
    setItem_idIsSet(true);
  }

  public void unsetItem_id() {
    __isset_bit_vector.clear(__ITEM_ID_ISSET_ID);
  }

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

  public void setItem_idIsSet(boolean value) {
    __isset_bit_vector.set(__ITEM_ID_ISSET_ID, value);
  }

  public double getDiscount() {
    return this.discount;
  }

  public void setDiscount(double discount) {
    this.discount = discount;
    setDiscountIsSet(true);
  }

  public void unsetDiscount() {
    __isset_bit_vector.clear(__DISCOUNT_ISSET_ID);
  }

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

  public void setDiscountIsSet(boolean value) {
    __isset_bit_vector.set(__DISCOUNT_ISSET_ID, value);
  }

  public double getQuantity() {
    return this.quantity;
  }

  public void setQuantity(double quantity) {
    this.quantity = quantity;
    setQuantityIsSet(true);
  }

  public void unsetQuantity() {
    __isset_bit_vector.clear(__QUANTITY_ISSET_ID);
  }

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

  public void setQuantityIsSet(boolean value) {
    __isset_bit_vector.set(__QUANTITY_ISSET_ID, value);
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case CART_ID:
      if (value == null) {
        unsetCart_id();
      } else {
        setCart_id((Long)value);
      }
      break;

    case ITEM_ID:
      if (value == null) {
        unsetItem_id();
      } else {
        setItem_id((Long)value);
      }
      break;

    case DISCOUNT:
      if (value == null) {
        unsetDiscount();
      } else {
        setDiscount((Double)value);
      }
      break;

    case QUANTITY:
      if (value == null) {
        unsetQuantity();
      } else {
        setQuantity((Double)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case CART_ID:
      return Long.valueOf(getCart_id());

    case ITEM_ID:
      return Long.valueOf(getItem_id());

    case DISCOUNT:
      return Double.valueOf(getDiscount());

    case QUANTITY:
      return Double.valueOf(getQuantity());

    }
    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 CART_ID:
      return isSetCart_id();
    case ITEM_ID:
      return isSetItem_id();
    case DISCOUNT:
      return isSetDiscount();
    case QUANTITY:
      return isSetQuantity();
    }
    throw new IllegalStateException();
  }

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

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

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

    boolean this_present_item_id = true;
    boolean that_present_item_id = true;
    if (this_present_item_id || that_present_item_id) {
      if (!(this_present_item_id && that_present_item_id))
        return false;
      if (this.item_id != that.item_id)
        return false;
    }

    boolean this_present_discount = true;
    boolean that_present_discount = true;
    if (this_present_discount || that_present_discount) {
      if (!(this_present_discount && that_present_discount))
        return false;
      if (this.discount != that.discount)
        return false;
    }

    boolean this_present_quantity = true;
    boolean that_present_quantity = true;
    if (this_present_quantity || that_present_quantity) {
      if (!(this_present_quantity && that_present_quantity))
        return false;
      if (this.quantity != that.quantity)
        return false;
    }

    return true;
  }

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

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

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

    lastComparison = Boolean.valueOf(isSetCart_id()).compareTo(typedOther.isSetCart_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetCart_id()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cart_id, typedOther.cart_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetItem_id()).compareTo(typedOther.isSetItem_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetItem_id()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.item_id, typedOther.item_id);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDiscount()).compareTo(typedOther.isSetDiscount());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDiscount()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.discount, typedOther.discount);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetQuantity()).compareTo(typedOther.isSetQuantity());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetQuantity()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.quantity, typedOther.quantity);
      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: // CART_ID
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.cart_id = iprot.readI64();
            setCart_idIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // ITEM_ID
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.item_id = iprot.readI64();
            setItem_idIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // DISCOUNT
          if (field.type == org.apache.thrift.protocol.TType.DOUBLE) {
            this.discount = iprot.readDouble();
            setDiscountIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // QUANTITY
          if (field.type == org.apache.thrift.protocol.TType.DOUBLE) {
            this.quantity = iprot.readDouble();
            setQuantityIsSet(true);
          } 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);
    oprot.writeFieldBegin(CART_ID_FIELD_DESC);
    oprot.writeI64(this.cart_id);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(ITEM_ID_FIELD_DESC);
    oprot.writeI64(this.item_id);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(DISCOUNT_FIELD_DESC);
    oprot.writeDouble(this.discount);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(QUANTITY_FIELD_DESC);
    oprot.writeDouble(this.quantity);
    oprot.writeFieldEnd();
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("cart_id:");
    sb.append(this.cart_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("item_id:");
    sb.append(this.item_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("discount:");
    sb.append(this.discount);
    first = false;
    if (!first) sb.append(", ");
    sb.append("quantity:");
    sb.append(this.quantity);
    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);
    }
  }

}