Subversion Repositories SmartDukaan

Rev

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

  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
  private static final TField BILL_NUMBER_FIELD_DESC = new TField("billNumber", TType.STRING, (short)2);
  private static final TField LINE_ITEM_FIELD_DESC = new TField("lineItem", TType.LIST, (short)3);
  private static final TField GENERATED_TIMESTAMP_FIELD_DESC = new TField("generatedTimestamp", TType.I64, (short)4);
  private static final TField GENERATED_BY_FIELD_DESC = new TField("generatedBy", TType.STRING, (short)5);

  private long id;
  private String billNumber;
  private List<LineItem> lineItem;
  private long generatedTimestamp;
  private String generatedBy;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    ID((short)1, "id"),
    BILL_NUMBER((short)2, "billNumber"),
    LINE_ITEM((short)3, "lineItem"),
    GENERATED_TIMESTAMP((short)4, "generatedTimestamp"),
    GENERATED_BY((short)5, "generatedBy");

    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 __ID_ISSET_ID = 0;
  private static final int __GENERATEDTIMESTAMP_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.ID, new FieldMetaData("id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.BILL_NUMBER, new FieldMetaData("billNumber", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.LINE_ITEM, new FieldMetaData("lineItem", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new StructMetaData(TType.STRUCT, LineItem.class))));
    put(_Fields.GENERATED_TIMESTAMP, new FieldMetaData("generatedTimestamp", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.GENERATED_BY, new FieldMetaData("generatedBy", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
  }});

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

  public Billing() {
  }

  public Billing(
    long id,
    String billNumber,
    List<LineItem> lineItem,
    long generatedTimestamp,
    String generatedBy)
  {
    this();
    this.id = id;
    setIdIsSet(true);
    this.billNumber = billNumber;
    this.lineItem = lineItem;
    this.generatedTimestamp = generatedTimestamp;
    setGeneratedTimestampIsSet(true);
    this.generatedBy = generatedBy;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Billing(Billing other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.id = other.id;
    if (other.isSetBillNumber()) {
      this.billNumber = other.billNumber;
    }
    if (other.isSetLineItem()) {
      List<LineItem> __this__lineItem = new ArrayList<LineItem>();
      for (LineItem other_element : other.lineItem) {
        __this__lineItem.add(new LineItem(other_element));
      }
      this.lineItem = __this__lineItem;
    }
    this.generatedTimestamp = other.generatedTimestamp;
    if (other.isSetGeneratedBy()) {
      this.generatedBy = other.generatedBy;
    }
  }

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

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

  public long getId() {
    return this.id;
  }

  public Billing setId(long id) {
    this.id = id;
    setIdIsSet(true);
    return this;
  }

  public void unsetId() {
    __isset_bit_vector.clear(__ID_ISSET_ID);
  }

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

  public void setIdIsSet(boolean value) {
    __isset_bit_vector.set(__ID_ISSET_ID, value);
  }

  public String getBillNumber() {
    return this.billNumber;
  }

  public Billing setBillNumber(String billNumber) {
    this.billNumber = billNumber;
    return this;
  }

  public void unsetBillNumber() {
    this.billNumber = null;
  }

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

  public void setBillNumberIsSet(boolean value) {
    if (!value) {
      this.billNumber = null;
    }
  }

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

  public java.util.Iterator<LineItem> getLineItemIterator() {
    return (this.lineItem == null) ? null : this.lineItem.iterator();
  }

  public void addToLineItem(LineItem elem) {
    if (this.lineItem == null) {
      this.lineItem = new ArrayList<LineItem>();
    }
    this.lineItem.add(elem);
  }

  public List<LineItem> getLineItem() {
    return this.lineItem;
  }

  public Billing setLineItem(List<LineItem> lineItem) {
    this.lineItem = lineItem;
    return this;
  }

  public void unsetLineItem() {
    this.lineItem = null;
  }

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

  public void setLineItemIsSet(boolean value) {
    if (!value) {
      this.lineItem = null;
    }
  }

  public long getGeneratedTimestamp() {
    return this.generatedTimestamp;
  }

  public Billing setGeneratedTimestamp(long generatedTimestamp) {
    this.generatedTimestamp = generatedTimestamp;
    setGeneratedTimestampIsSet(true);
    return this;
  }

  public void unsetGeneratedTimestamp() {
    __isset_bit_vector.clear(__GENERATEDTIMESTAMP_ISSET_ID);
  }

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

  public void setGeneratedTimestampIsSet(boolean value) {
    __isset_bit_vector.set(__GENERATEDTIMESTAMP_ISSET_ID, value);
  }

  public String getGeneratedBy() {
    return this.generatedBy;
  }

  public Billing setGeneratedBy(String generatedBy) {
    this.generatedBy = generatedBy;
    return this;
  }

  public void unsetGeneratedBy() {
    this.generatedBy = null;
  }

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

  public void setGeneratedByIsSet(boolean value) {
    if (!value) {
      this.generatedBy = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case ID:
      if (value == null) {
        unsetId();
      } else {
        setId((Long)value);
      }
      break;

    case BILL_NUMBER:
      if (value == null) {
        unsetBillNumber();
      } else {
        setBillNumber((String)value);
      }
      break;

    case LINE_ITEM:
      if (value == null) {
        unsetLineItem();
      } else {
        setLineItem((List<LineItem>)value);
      }
      break;

    case GENERATED_TIMESTAMP:
      if (value == null) {
        unsetGeneratedTimestamp();
      } else {
        setGeneratedTimestamp((Long)value);
      }
      break;

    case GENERATED_BY:
      if (value == null) {
        unsetGeneratedBy();
      } else {
        setGeneratedBy((String)value);
      }
      break;

    }
  }

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

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case ID:
      return new Long(getId());

    case BILL_NUMBER:
      return getBillNumber();

    case LINE_ITEM:
      return getLineItem();

    case GENERATED_TIMESTAMP:
      return new Long(getGeneratedTimestamp());

    case GENERATED_BY:
      return getGeneratedBy();

    }
    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 ID:
      return isSetId();
    case BILL_NUMBER:
      return isSetBillNumber();
    case LINE_ITEM:
      return isSetLineItem();
    case GENERATED_TIMESTAMP:
      return isSetGeneratedTimestamp();
    case GENERATED_BY:
      return isSetGeneratedBy();
    }
    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 Billing)
      return this.equals((Billing)that);
    return false;
  }

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

    boolean this_present_id = true;
    boolean that_present_id = true;
    if (this_present_id || that_present_id) {
      if (!(this_present_id && that_present_id))
        return false;
      if (this.id != that.id)
        return false;
    }

    boolean this_present_billNumber = true && this.isSetBillNumber();
    boolean that_present_billNumber = true && that.isSetBillNumber();
    if (this_present_billNumber || that_present_billNumber) {
      if (!(this_present_billNumber && that_present_billNumber))
        return false;
      if (!this.billNumber.equals(that.billNumber))
        return false;
    }

    boolean this_present_lineItem = true && this.isSetLineItem();
    boolean that_present_lineItem = true && that.isSetLineItem();
    if (this_present_lineItem || that_present_lineItem) {
      if (!(this_present_lineItem && that_present_lineItem))
        return false;
      if (!this.lineItem.equals(that.lineItem))
        return false;
    }

    boolean this_present_generatedTimestamp = true;
    boolean that_present_generatedTimestamp = true;
    if (this_present_generatedTimestamp || that_present_generatedTimestamp) {
      if (!(this_present_generatedTimestamp && that_present_generatedTimestamp))
        return false;
      if (this.generatedTimestamp != that.generatedTimestamp)
        return false;
    }

    boolean this_present_generatedBy = true && this.isSetGeneratedBy();
    boolean that_present_generatedBy = true && that.isSetGeneratedBy();
    if (this_present_generatedBy || that_present_generatedBy) {
      if (!(this_present_generatedBy && that_present_generatedBy))
        return false;
      if (!this.generatedBy.equals(that.generatedBy))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    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 ID:
            if (field.type == TType.I64) {
              this.id = iprot.readI64();
              setIdIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case BILL_NUMBER:
            if (field.type == TType.STRING) {
              this.billNumber = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case LINE_ITEM:
            if (field.type == TType.LIST) {
              {
                TList _list9 = iprot.readListBegin();
                this.lineItem = new ArrayList<LineItem>(_list9.size);
                for (int _i10 = 0; _i10 < _list9.size; ++_i10)
                {
                  LineItem _elem11;
                  _elem11 = new LineItem();
                  _elem11.read(iprot);
                  this.lineItem.add(_elem11);
                }
                iprot.readListEnd();
              }
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case GENERATED_TIMESTAMP:
            if (field.type == TType.I64) {
              this.generatedTimestamp = iprot.readI64();
              setGeneratedTimestampIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case GENERATED_BY:
            if (field.type == TType.STRING) {
              this.generatedBy = 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(ID_FIELD_DESC);
    oprot.writeI64(this.id);
    oprot.writeFieldEnd();
    if (this.billNumber != null) {
      oprot.writeFieldBegin(BILL_NUMBER_FIELD_DESC);
      oprot.writeString(this.billNumber);
      oprot.writeFieldEnd();
    }
    if (this.lineItem != null) {
      oprot.writeFieldBegin(LINE_ITEM_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRUCT, this.lineItem.size()));
        for (LineItem _iter12 : this.lineItem)
        {
          _iter12.write(oprot);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(GENERATED_TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.generatedTimestamp);
    oprot.writeFieldEnd();
    if (this.generatedBy != null) {
      oprot.writeFieldBegin(GENERATED_BY_FIELD_DESC);
      oprot.writeString(this.generatedBy);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("id:");
    sb.append(this.id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("billNumber:");
    if (this.billNumber == null) {
      sb.append("null");
    } else {
      sb.append(this.billNumber);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("lineItem:");
    if (this.lineItem == null) {
      sb.append("null");
    } else {
      sb.append(this.lineItem);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("generatedTimestamp:");
    sb.append(this.generatedTimestamp);
    first = false;
    if (!first) sb.append(", ");
    sb.append("generatedBy:");
    if (this.generatedBy == null) {
      sb.append("null");
    } else {
      sb.append(this.generatedBy);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

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

}