/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package com.vesoft.nebula.storage;

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;
import java.util.BitSet;
import java.util.Arrays;
import com.facebook.thrift.*;
import com.facebook.thrift.annotations.*;
import com.facebook.thrift.async.*;
import com.facebook.thrift.meta_data.*;
import com.facebook.thrift.server.*;
import com.facebook.thrift.transport.*;
import com.facebook.thrift.protocol.*;

@SuppressWarnings({ "unused", "serial" })
public class NewTag implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("NewTag");
  private static final TField TAG_ID_FIELD_DESC = new TField("tag_id", TType.I32, (short)1);
  private static final TField PROPS_FIELD_DESC = new TField("props", TType.LIST, (short)2);

  public int tag_id;
  public List<com.vesoft.nebula.Value> props;
  public static final int TAG_ID = 1;
  public static final int PROPS = 2;

  // isset id assignments
  private static final int __TAG_ID_ISSET_ID = 0;
  private BitSet __isset_bit_vector = new BitSet(1);

  public static final Map<Integer, FieldMetaData> metaDataMap;

  static {
    Map<Integer, FieldMetaData> tmpMetaDataMap = new HashMap<Integer, FieldMetaData>();
    tmpMetaDataMap.put(TAG_ID, new FieldMetaData("tag_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I32)));
    tmpMetaDataMap.put(PROPS, new FieldMetaData("props", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new StructMetaData(TType.STRUCT, com.vesoft.nebula.Value.class))));
    metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap);
  }

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

  public NewTag() {
  }

  public NewTag(
      int tag_id,
      List<com.vesoft.nebula.Value> props) {
    this();
    this.tag_id = tag_id;
    setTag_idIsSet(true);
    this.props = props;
  }

  public static class Builder {
    private int tag_id;
    private List<com.vesoft.nebula.Value> props;

    BitSet __optional_isset = new BitSet(1);

    public Builder() {
    }

    public Builder setTag_id(final int tag_id) {
      this.tag_id = tag_id;
      __optional_isset.set(__TAG_ID_ISSET_ID, true);
      return this;
    }

    public Builder setProps(final List<com.vesoft.nebula.Value> props) {
      this.props = props;
      return this;
    }

    public NewTag build() {
      NewTag result = new NewTag();
      if (__optional_isset.get(__TAG_ID_ISSET_ID)) {
        result.setTag_id(this.tag_id);
      }
      result.setProps(this.props);
      return result;
    }
  }

  public static Builder builder() {
    return new Builder();
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public NewTag(NewTag other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.tag_id = TBaseHelper.deepCopy(other.tag_id);
    if (other.isSetProps()) {
      this.props = TBaseHelper.deepCopy(other.props);
    }
  }

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

  public int getTag_id() {
    return this.tag_id;
  }

  public NewTag setTag_id(int tag_id) {
    this.tag_id = tag_id;
    setTag_idIsSet(true);
    return this;
  }

  public void unsetTag_id() {
    __isset_bit_vector.clear(__TAG_ID_ISSET_ID);
  }

  // Returns true if field tag_id is set (has been assigned a value) and false otherwise
  public boolean isSetTag_id() {
    return __isset_bit_vector.get(__TAG_ID_ISSET_ID);
  }

  public void setTag_idIsSet(boolean __value) {
    __isset_bit_vector.set(__TAG_ID_ISSET_ID, __value);
  }

  public List<com.vesoft.nebula.Value> getProps() {
    return this.props;
  }

  public NewTag setProps(List<com.vesoft.nebula.Value> props) {
    this.props = props;
    return this;
  }

  public void unsetProps() {
    this.props = null;
  }

  // Returns true if field props is set (has been assigned a value) and false otherwise
  public boolean isSetProps() {
    return this.props != null;
  }

  public void setPropsIsSet(boolean __value) {
    if (!__value) {
      this.props = null;
    }
  }

  @SuppressWarnings("unchecked")
  public void setFieldValue(int fieldID, Object __value) {
    switch (fieldID) {
    case TAG_ID:
      if (__value == null) {
        unsetTag_id();
      } else {
        setTag_id((Integer)__value);
      }
      break;

    case PROPS:
      if (__value == null) {
        unsetProps();
      } else {
        setProps((List<com.vesoft.nebula.Value>)__value);
      }
      break;

    default:
      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
    }
  }

  public Object getFieldValue(int fieldID) {
    switch (fieldID) {
    case TAG_ID:
      return new Integer(getTag_id());

    case PROPS:
      return getProps();

    default:
      throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
    }
  }

  @Override
  public boolean equals(Object _that) {
    if (_that == null)
      return false;
    if (this == _that)
      return true;
    if (!(_that instanceof NewTag))
      return false;
    NewTag that = (NewTag)_that;

    if (!TBaseHelper.equalsNobinary(this.tag_id, that.tag_id)) { return false; }

    if (!TBaseHelper.equalsNobinary(this.isSetProps(), that.isSetProps(), this.props, that.props)) { return false; }

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {tag_id, props});
  }

  public void read(TProtocol iprot) throws TException {
    TField __field;
    iprot.readStructBegin(metaDataMap);
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) { 
        break;
      }
      switch (__field.id)
      {
        case TAG_ID:
          if (__field.type == TType.I32) {
            this.tag_id = iprot.readI32();
            setTag_idIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case PROPS:
          if (__field.type == TType.LIST) {
            {
              TList _list92 = iprot.readListBegin();
              this.props = new ArrayList<com.vesoft.nebula.Value>(Math.max(0, _list92.size));
              for (int _i93 = 0; 
                   (_list92.size < 0) ? iprot.peekList() : (_i93 < _list92.size); 
                   ++_i93)
              {
                com.vesoft.nebula.Value _elem94;
                _elem94 = new com.vesoft.nebula.Value();
                _elem94.read(iprot);
                this.props.add(_elem94);
              }
              iprot.readListEnd();
            }
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();


    // check for required fields of primitive type, which can't be checked in the validate method
    validate();
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(TAG_ID_FIELD_DESC);
    oprot.writeI32(this.tag_id);
    oprot.writeFieldEnd();
    if (this.props != null) {
      oprot.writeFieldBegin(PROPS_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRUCT, this.props.size()));
        for (com.vesoft.nebula.Value _iter95 : this.props)        {
          _iter95.write(oprot);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

  @Override
  public String toString() {
    return toString(1, true);
  }

  @Override
  public String toString(int indent, boolean prettyPrint) {
    String indentStr = prettyPrint ? TBaseHelper.getIndentedString(indent) : "";
    String newLine = prettyPrint ? "\n" : "";
    String space = prettyPrint ? " " : "";
    StringBuilder sb = new StringBuilder("NewTag");
    sb.append(space);
    sb.append("(");
    sb.append(newLine);
    boolean first = true;

    sb.append(indentStr);
    sb.append("tag_id");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getTag_id(), indent + 1, prettyPrint));
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("props");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getProps() == null) {
      sb.append("null");
    } else {
      sb.append(TBaseHelper.toString(this.getProps(), indent + 1, prettyPrint));
    }
    first = false;
    sb.append(newLine + TBaseHelper.reduceIndent(indentStr));
    sb.append(")");
    return sb.toString();
  }

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

}

