Subversion Repositories SmartDukaan

Rev

Rev 412 | 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.logistics;

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

  private static final TField AWB_FIELD_DESC = new TField("awb", TType.STRING, (short)1);
  private static final TField PROVIDER_ID_FIELD_DESC = new TField("provider_id", TType.I64, (short)2);
  private static final TField UPDATES_FIELD_DESC = new TField("updates", TType.LIST, (short)3);
  private static final TField CURRENT_UPDATE_FIELD_DESC = new TField("currentUpdate", TType.STRUCT, (short)4);

  private String awb;
  private long provider_id;
  private List<ShipmentUpdate> updates;
  private ShipmentUpdate currentUpdate;

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements TFieldIdEnum {
    AWB((short)1, "awb"),
    PROVIDER_ID((short)2, "provider_id"),
    UPDATES((short)3, "updates"),
    CURRENT_UPDATE((short)4, "currentUpdate");

    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 __PROVIDER_ID_ISSET_ID = 0;
  private BitSet __isset_bit_vector = new BitSet(1);

  public static final Map<_Fields, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new EnumMap<_Fields, FieldMetaData>(_Fields.class) {{
    put(_Fields.AWB, new FieldMetaData("awb", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.PROVIDER_ID, new FieldMetaData("provider_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.UPDATES, new FieldMetaData("updates", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new StructMetaData(TType.STRUCT, ShipmentUpdate.class))));
    put(_Fields.CURRENT_UPDATE, new FieldMetaData("currentUpdate", TFieldRequirementType.DEFAULT, 
        new StructMetaData(TType.STRUCT, ShipmentUpdate.class)));
  }});

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

  public ShipmentStatusInfo() {
  }

  public ShipmentStatusInfo(
    String awb,
    long provider_id,
    List<ShipmentUpdate> updates,
    ShipmentUpdate currentUpdate)
  {
    this();
    this.awb = awb;
    this.provider_id = provider_id;
    setProvider_idIsSet(true);
    this.updates = updates;
    this.currentUpdate = currentUpdate;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public ShipmentStatusInfo(ShipmentStatusInfo other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetAwb()) {
      this.awb = other.awb;
    }
    this.provider_id = other.provider_id;
    if (other.isSetUpdates()) {
      List<ShipmentUpdate> __this__updates = new ArrayList<ShipmentUpdate>();
      for (ShipmentUpdate other_element : other.updates) {
        __this__updates.add(new ShipmentUpdate(other_element));
      }
      this.updates = __this__updates;
    }
    if (other.isSetCurrentUpdate()) {
      this.currentUpdate = new ShipmentUpdate(other.currentUpdate);
    }
  }

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

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

  public String getAwb() {
    return this.awb;
  }

  public ShipmentStatusInfo setAwb(String awb) {
    this.awb = awb;
    return this;
  }

  public void unsetAwb() {
    this.awb = null;
  }

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

  public void setAwbIsSet(boolean value) {
    if (!value) {
      this.awb = null;
    }
  }

  public long getProvider_id() {
    return this.provider_id;
  }

  public ShipmentStatusInfo setProvider_id(long provider_id) {
    this.provider_id = provider_id;
    setProvider_idIsSet(true);
    return this;
  }

  public void unsetProvider_id() {
    __isset_bit_vector.clear(__PROVIDER_ID_ISSET_ID);
  }

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

  public void setProvider_idIsSet(boolean value) {
    __isset_bit_vector.set(__PROVIDER_ID_ISSET_ID, value);
  }

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

  public java.util.Iterator<ShipmentUpdate> getUpdatesIterator() {
    return (this.updates == null) ? null : this.updates.iterator();
  }

  public void addToUpdates(ShipmentUpdate elem) {
    if (this.updates == null) {
      this.updates = new ArrayList<ShipmentUpdate>();
    }
    this.updates.add(elem);
  }

  public List<ShipmentUpdate> getUpdates() {
    return this.updates;
  }

  public ShipmentStatusInfo setUpdates(List<ShipmentUpdate> updates) {
    this.updates = updates;
    return this;
  }

  public void unsetUpdates() {
    this.updates = null;
  }

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

  public void setUpdatesIsSet(boolean value) {
    if (!value) {
      this.updates = null;
    }
  }

  public ShipmentUpdate getCurrentUpdate() {
    return this.currentUpdate;
  }

  public ShipmentStatusInfo setCurrentUpdate(ShipmentUpdate currentUpdate) {
    this.currentUpdate = currentUpdate;
    return this;
  }

  public void unsetCurrentUpdate() {
    this.currentUpdate = null;
  }

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

  public void setCurrentUpdateIsSet(boolean value) {
    if (!value) {
      this.currentUpdate = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case AWB:
      if (value == null) {
        unsetAwb();
      } else {
        setAwb((String)value);
      }
      break;

    case PROVIDER_ID:
      if (value == null) {
        unsetProvider_id();
      } else {
        setProvider_id((Long)value);
      }
      break;

    case UPDATES:
      if (value == null) {
        unsetUpdates();
      } else {
        setUpdates((List<ShipmentUpdate>)value);
      }
      break;

    case CURRENT_UPDATE:
      if (value == null) {
        unsetCurrentUpdate();
      } else {
        setCurrentUpdate((ShipmentUpdate)value);
      }
      break;

    }
  }

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

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case AWB:
      return getAwb();

    case PROVIDER_ID:
      return new Long(getProvider_id());

    case UPDATES:
      return getUpdates();

    case CURRENT_UPDATE:
      return getCurrentUpdate();

    }
    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 AWB:
      return isSetAwb();
    case PROVIDER_ID:
      return isSetProvider_id();
    case UPDATES:
      return isSetUpdates();
    case CURRENT_UPDATE:
      return isSetCurrentUpdate();
    }
    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 ShipmentStatusInfo)
      return this.equals((ShipmentStatusInfo)that);
    return false;
  }

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

    boolean this_present_awb = true && this.isSetAwb();
    boolean that_present_awb = true && that.isSetAwb();
    if (this_present_awb || that_present_awb) {
      if (!(this_present_awb && that_present_awb))
        return false;
      if (!this.awb.equals(that.awb))
        return false;
    }

    boolean this_present_provider_id = true;
    boolean that_present_provider_id = true;
    if (this_present_provider_id || that_present_provider_id) {
      if (!(this_present_provider_id && that_present_provider_id))
        return false;
      if (this.provider_id != that.provider_id)
        return false;
    }

    boolean this_present_updates = true && this.isSetUpdates();
    boolean that_present_updates = true && that.isSetUpdates();
    if (this_present_updates || that_present_updates) {
      if (!(this_present_updates && that_present_updates))
        return false;
      if (!this.updates.equals(that.updates))
        return false;
    }

    boolean this_present_currentUpdate = true && this.isSetCurrentUpdate();
    boolean that_present_currentUpdate = true && that.isSetCurrentUpdate();
    if (this_present_currentUpdate || that_present_currentUpdate) {
      if (!(this_present_currentUpdate && that_present_currentUpdate))
        return false;
      if (!this.currentUpdate.equals(that.currentUpdate))
        return false;
    }

    return true;
  }

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

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

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

    lastComparison = Boolean.valueOf(isSetAwb()).compareTo(isSetAwb());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(awb, typedOther.awb);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetProvider_id()).compareTo(isSetProvider_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(provider_id, typedOther.provider_id);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetUpdates()).compareTo(isSetUpdates());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(updates, typedOther.updates);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetCurrentUpdate()).compareTo(isSetCurrentUpdate());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(currentUpdate, typedOther.currentUpdate);
    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 AWB:
            if (field.type == TType.STRING) {
              this.awb = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case PROVIDER_ID:
            if (field.type == TType.I64) {
              this.provider_id = iprot.readI64();
              setProvider_idIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case UPDATES:
            if (field.type == TType.LIST) {
              {
                TList _list0 = iprot.readListBegin();
                this.updates = new ArrayList<ShipmentUpdate>(_list0.size);
                for (int _i1 = 0; _i1 < _list0.size; ++_i1)
                {
                  ShipmentUpdate _elem2;
                  _elem2 = new ShipmentUpdate();
                  _elem2.read(iprot);
                  this.updates.add(_elem2);
                }
                iprot.readListEnd();
              }
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case CURRENT_UPDATE:
            if (field.type == TType.STRUCT) {
              this.currentUpdate = new ShipmentUpdate();
              this.currentUpdate.read(iprot);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
        }
        iprot.readFieldEnd();
      }
    }
    iprot.readStructEnd();
    validate();
  }

  public void write(TProtocol oprot) throws TException {
    validate();

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.awb != null) {
      oprot.writeFieldBegin(AWB_FIELD_DESC);
      oprot.writeString(this.awb);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(PROVIDER_ID_FIELD_DESC);
    oprot.writeI64(this.provider_id);
    oprot.writeFieldEnd();
    if (this.updates != null) {
      oprot.writeFieldBegin(UPDATES_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRUCT, this.updates.size()));
        for (ShipmentUpdate _iter3 : this.updates)
        {
          _iter3.write(oprot);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.currentUpdate != null) {
      oprot.writeFieldBegin(CURRENT_UPDATE_FIELD_DESC);
      this.currentUpdate.write(oprot);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("awb:");
    if (this.awb == null) {
      sb.append("null");
    } else {
      sb.append(this.awb);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("provider_id:");
    sb.append(this.provider_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("updates:");
    if (this.updates == null) {
      sb.append("null");
    } else {
      sb.append(this.updates);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("currentUpdate:");
    if (this.currentUpdate == null) {
      sb.append("null");
    } else {
      sb.append(this.currentUpdate);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

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

}