Subversion Repositories SmartDukaan

Rev

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

  private static final TField ID_FIELD_DESC = new TField("id", TType.I64, (short)1);
  private static final TField LABEL_FIELD_DESC = new TField("label", TType.STRING, (short)2);
  private static final TField DESCRIPTION_FIELD_DESC = new TField("description", TType.STRING, (short)3);
  private static final TField PARENT_CATEGORY_ID_FIELD_DESC = new TField("parent_category_id", TType.I64, (short)4);
  private static final TField CHILDREN_CATEGORY_IDS_FIELD_DESC = new TField("children_category_ids", TType.LIST, (short)5);

  private long id;
  private String label;
  private String description;
  private long parent_category_id;
  private List<Long> children_category_ids;

  /** 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"),
    LABEL((short)2, "label"),
    DESCRIPTION((short)3, "description"),
    PARENT_CATEGORY_ID((short)4, "parent_category_id"),
    /**
     * This field should not be used.
     */
    CHILDREN_CATEGORY_IDS((short)5, "children_category_ids");

    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 __PARENT_CATEGORY_ID_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.LABEL, new FieldMetaData("label", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.DESCRIPTION, new FieldMetaData("description", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    put(_Fields.PARENT_CATEGORY_ID, new FieldMetaData("parent_category_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I64)));
    put(_Fields.CHILDREN_CATEGORY_IDS, new FieldMetaData("children_category_ids", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new FieldValueMetaData(TType.I64))));
  }});

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

  public Category() {
  }

  public Category(
    long id,
    String label,
    String description,
    long parent_category_id,
    List<Long> children_category_ids)
  {
    this();
    this.id = id;
    setIdIsSet(true);
    this.label = label;
    this.description = description;
    this.parent_category_id = parent_category_id;
    setParent_category_idIsSet(true);
    this.children_category_ids = children_category_ids;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public Category(Category other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.id = other.id;
    if (other.isSetLabel()) {
      this.label = other.label;
    }
    if (other.isSetDescription()) {
      this.description = other.description;
    }
    this.parent_category_id = other.parent_category_id;
    if (other.isSetChildren_category_ids()) {
      List<Long> __this__children_category_ids = new ArrayList<Long>();
      for (Long other_element : other.children_category_ids) {
        __this__children_category_ids.add(other_element);
      }
      this.children_category_ids = __this__children_category_ids;
    }
  }

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

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

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

  public Category 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 getLabel() {
    return this.label;
  }

  public Category setLabel(String label) {
    this.label = label;
    return this;
  }

  public void unsetLabel() {
    this.label = null;
  }

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

  public void setLabelIsSet(boolean value) {
    if (!value) {
      this.label = null;
    }
  }

  public String getDescription() {
    return this.description;
  }

  public Category setDescription(String description) {
    this.description = description;
    return this;
  }

  public void unsetDescription() {
    this.description = null;
  }

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

  public void setDescriptionIsSet(boolean value) {
    if (!value) {
      this.description = null;
    }
  }

  public long getParent_category_id() {
    return this.parent_category_id;
  }

  public Category setParent_category_id(long parent_category_id) {
    this.parent_category_id = parent_category_id;
    setParent_category_idIsSet(true);
    return this;
  }

  public void unsetParent_category_id() {
    __isset_bit_vector.clear(__PARENT_CATEGORY_ID_ISSET_ID);
  }

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

  public void setParent_category_idIsSet(boolean value) {
    __isset_bit_vector.set(__PARENT_CATEGORY_ID_ISSET_ID, value);
  }

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

  public java.util.Iterator<Long> getChildren_category_idsIterator() {
    return (this.children_category_ids == null) ? null : this.children_category_ids.iterator();
  }

  public void addToChildren_category_ids(long elem) {
    if (this.children_category_ids == null) {
      this.children_category_ids = new ArrayList<Long>();
    }
    this.children_category_ids.add(elem);
  }

  /**
   * This field should not be used.
   */
  public List<Long> getChildren_category_ids() {
    return this.children_category_ids;
  }

  /**
   * This field should not be used.
   */
  public Category setChildren_category_ids(List<Long> children_category_ids) {
    this.children_category_ids = children_category_ids;
    return this;
  }

  public void unsetChildren_category_ids() {
    this.children_category_ids = null;
  }

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

  public void setChildren_category_idsIsSet(boolean value) {
    if (!value) {
      this.children_category_ids = null;
    }
  }

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

    case LABEL:
      if (value == null) {
        unsetLabel();
      } else {
        setLabel((String)value);
      }
      break;

    case DESCRIPTION:
      if (value == null) {
        unsetDescription();
      } else {
        setDescription((String)value);
      }
      break;

    case PARENT_CATEGORY_ID:
      if (value == null) {
        unsetParent_category_id();
      } else {
        setParent_category_id((Long)value);
      }
      break;

    case CHILDREN_CATEGORY_IDS:
      if (value == null) {
        unsetChildren_category_ids();
      } else {
        setChildren_category_ids((List<Long>)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 LABEL:
      return getLabel();

    case DESCRIPTION:
      return getDescription();

    case PARENT_CATEGORY_ID:
      return new Long(getParent_category_id());

    case CHILDREN_CATEGORY_IDS:
      return getChildren_category_ids();

    }
    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 LABEL:
      return isSetLabel();
    case DESCRIPTION:
      return isSetDescription();
    case PARENT_CATEGORY_ID:
      return isSetParent_category_id();
    case CHILDREN_CATEGORY_IDS:
      return isSetChildren_category_ids();
    }
    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 Category)
      return this.equals((Category)that);
    return false;
  }

  public boolean equals(Category 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_label = true && this.isSetLabel();
    boolean that_present_label = true && that.isSetLabel();
    if (this_present_label || that_present_label) {
      if (!(this_present_label && that_present_label))
        return false;
      if (!this.label.equals(that.label))
        return false;
    }

    boolean this_present_description = true && this.isSetDescription();
    boolean that_present_description = true && that.isSetDescription();
    if (this_present_description || that_present_description) {
      if (!(this_present_description && that_present_description))
        return false;
      if (!this.description.equals(that.description))
        return false;
    }

    boolean this_present_parent_category_id = true;
    boolean that_present_parent_category_id = true;
    if (this_present_parent_category_id || that_present_parent_category_id) {
      if (!(this_present_parent_category_id && that_present_parent_category_id))
        return false;
      if (this.parent_category_id != that.parent_category_id)
        return false;
    }

    boolean this_present_children_category_ids = true && this.isSetChildren_category_ids();
    boolean that_present_children_category_ids = true && that.isSetChildren_category_ids();
    if (this_present_children_category_ids || that_present_children_category_ids) {
      if (!(this_present_children_category_ids && that_present_children_category_ids))
        return false;
      if (!this.children_category_ids.equals(that.children_category_ids))
        return false;
    }

    return true;
  }

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

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

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

    lastComparison = Boolean.valueOf(isSetId()).compareTo(isSetId());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(id, typedOther.id);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetLabel()).compareTo(isSetLabel());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(label, typedOther.label);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetDescription()).compareTo(isSetDescription());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(description, typedOther.description);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetParent_category_id()).compareTo(isSetParent_category_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(parent_category_id, typedOther.parent_category_id);
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetChildren_category_ids()).compareTo(isSetChildren_category_ids());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(children_category_ids, typedOther.children_category_ids);
    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 ID:
            if (field.type == TType.I64) {
              this.id = iprot.readI64();
              setIdIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case LABEL:
            if (field.type == TType.STRING) {
              this.label = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case DESCRIPTION:
            if (field.type == TType.STRING) {
              this.description = iprot.readString();
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case PARENT_CATEGORY_ID:
            if (field.type == TType.I64) {
              this.parent_category_id = iprot.readI64();
              setParent_category_idIsSet(true);
            } else { 
              TProtocolUtil.skip(iprot, field.type);
            }
            break;
          case CHILDREN_CATEGORY_IDS:
            if (field.type == TType.LIST) {
              {
                TList _list10 = iprot.readListBegin();
                this.children_category_ids = new ArrayList<Long>(_list10.size);
                for (int _i11 = 0; _i11 < _list10.size; ++_i11)
                {
                  long _elem12;
                  _elem12 = iprot.readI64();
                  this.children_category_ids.add(_elem12);
                }
                iprot.readListEnd();
              }
            } 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.label != null) {
      oprot.writeFieldBegin(LABEL_FIELD_DESC);
      oprot.writeString(this.label);
      oprot.writeFieldEnd();
    }
    if (this.description != null) {
      oprot.writeFieldBegin(DESCRIPTION_FIELD_DESC);
      oprot.writeString(this.description);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(PARENT_CATEGORY_ID_FIELD_DESC);
    oprot.writeI64(this.parent_category_id);
    oprot.writeFieldEnd();
    if (this.children_category_ids != null) {
      oprot.writeFieldBegin(CHILDREN_CATEGORY_IDS_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.I64, this.children_category_ids.size()));
        for (long _iter13 : this.children_category_ids)
        {
          oprot.writeI64(_iter13);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("id:");
    sb.append(this.id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("label:");
    if (this.label == null) {
      sb.append("null");
    } else {
      sb.append(this.label);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("description:");
    if (this.description == null) {
      sb.append("null");
    } else {
      sb.append(this.description);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("parent_category_id:");
    sb.append(this.parent_category_id);
    first = false;
    if (!first) sb.append(", ");
    sb.append("children_category_ids:");
    if (this.children_category_ids == null) {
      sb.append("null");
    } else {
      sb.append(this.children_category_ids);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

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

}