Subversion Repositories SmartDukaan

Rev

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.catalog;

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

  private static final TField IS_ACTIVE_FIELD_DESC = new TField("isActive", TType.BOOL, (short)1);
  private static final TField IS_RISKY_FIELD_DESC = new TField("isRisky", TType.BOOL, (short)2);
  private static final TField QUANTITY_FIELD_DESC = new TField("quantity", TType.I64, (short)3);

  private boolean isActive;
  private boolean isRisky;
  private long quantity;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    IS_ACTIVE((short)1, "isActive"),
    IS_RISKY((short)2, "isRisky"),
    QUANTITY((short)3, "quantity");

    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 __ISACTIVE_ISSET_ID = 0;
  private static final int __ISRISKY_ISSET_ID = 1;
  private static final int __QUANTITY_ISSET_ID = 2;
  private BitSet __isset_bit_vector = new BitSet(3);

  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    put(_Fields.IS_ACTIVE, new FieldMetaData("isActive", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.BOOL)));
    put(_Fields.IS_RISKY, new FieldMetaData("isRisky", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.BOOL)));
    put(_Fields.QUANTITY, new FieldMetaData("quantity", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.I64)));
  }});

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

  public ItemShippingInfo() {
  }

  public ItemShippingInfo(
    boolean isActive)
  {
    this();
    this.isActive = isActive;
    setIsActiveIsSet(true);
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public ItemShippingInfo(ItemShippingInfo other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.isActive = other.isActive;
    this.isRisky = other.isRisky;
    this.quantity = other.quantity;
  }

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

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

  public boolean isIsActive() {
    return this.isActive;
  }

  public ItemShippingInfo setIsActive(boolean isActive) {
    this.isActive = isActive;
    setIsActiveIsSet(true);
    return this;
  }

  public void unsetIsActive() {
    __isset_bit_vector.clear(__ISACTIVE_ISSET_ID);
  }

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

  public void setIsActiveIsSet(boolean value) {
    __isset_bit_vector.set(__ISACTIVE_ISSET_ID, value);
  }

  public boolean isIsRisky() {
    return this.isRisky;
  }

  public ItemShippingInfo setIsRisky(boolean isRisky) {
    this.isRisky = isRisky;
    setIsRiskyIsSet(true);
    return this;
  }

  public void unsetIsRisky() {
    __isset_bit_vector.clear(__ISRISKY_ISSET_ID);
  }

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

  public void setIsRiskyIsSet(boolean value) {
    __isset_bit_vector.set(__ISRISKY_ISSET_ID, value);
  }

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

  public ItemShippingInfo setQuantity(long quantity) {
    this.quantity = quantity;
    setQuantityIsSet(true);
    return this;
  }

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

  /** Returns true if field quantity is set (has been asigned 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 IS_ACTIVE:
      if (value == null) {
        unsetIsActive();
      } else {
        setIsActive((Boolean)value);
      }
      break;

    case IS_RISKY:
      if (value == null) {
        unsetIsRisky();
      } else {
        setIsRisky((Boolean)value);
      }
      break;

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

    }
  }

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

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case IS_ACTIVE:
      return new Boolean(isIsActive());

    case IS_RISKY:
      return new Boolean(isIsRisky());

    case QUANTITY:
      return new Long(getQuantity());

    }
    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 IS_ACTIVE:
      return isSetIsActive();
    case IS_RISKY:
      return isSetIsRisky();
    case QUANTITY:
      return isSetQuantity();
    }
    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 ItemShippingInfo)
      return this.equals((ItemShippingInfo)that);
    return false;
  }

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

    boolean this_present_isActive = true;
    boolean that_present_isActive = true;
    if (this_present_isActive || that_present_isActive) {
      if (!(this_present_isActive && that_present_isActive))
        return false;
      if (this.isActive != that.isActive)
        return false;
    }

    boolean this_present_isRisky = true && this.isSetIsRisky();
    boolean that_present_isRisky = true && that.isSetIsRisky();
    if (this_present_isRisky || that_present_isRisky) {
      if (!(this_present_isRisky && that_present_isRisky))
        return false;
      if (this.isRisky != that.isRisky)
        return false;
    }

    boolean this_present_quantity = true && this.isSetQuantity();
    boolean that_present_quantity = true && that.isSetQuantity();
    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(ItemShippingInfo other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

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

    lastComparison = Boolean.valueOf(isSetIsActive()).compareTo(isSetIsActive());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(isActive, typedOther.isActive);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetIsRisky()).compareTo(isSetIsRisky());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(isRisky, typedOther.isRisky);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetQuantity()).compareTo(isSetQuantity());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(quantity, typedOther.quantity);
    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 IS_ACTIVE:
            if (field.type == TType.BOOL) {
              this.isActive = iprot.readBool();
              setIsActiveIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case IS_RISKY:
            if (field.type == TType.BOOL) {
              this.isRisky = iprot.readBool();
              setIsRiskyIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case QUANTITY:
            if (field.type == TType.I64) {
              this.quantity = iprot.readI64();
              setQuantityIsSet(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(IS_ACTIVE_FIELD_DESC);
    oprot.writeBool(this.isActive);
    oprot.writeFieldEnd();
    if (isSetIsRisky()) {
      oprot.writeFieldBegin(IS_RISKY_FIELD_DESC);
      oprot.writeBool(this.isRisky);
      oprot.writeFieldEnd();
    }
    if (isSetQuantity()) {
      oprot.writeFieldBegin(QUANTITY_FIELD_DESC);
      oprot.writeI64(this.quantity);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("isActive:");
    sb.append(this.isActive);
    first = false;
    if (isSetIsRisky()) {
      if (!first) sb.append(", ");
      sb.append("isRisky:");
      sb.append(this.isRisky);
      first = false;
    }
    if (isSetQuantity()) {
      if (!first) sb.append(", ");
      sb.append("quantity:");
      sb.append(this.quantity);
      first = false;
    }
    sb.append(")");
    return sb.toString();
  }

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

}