/**
 * 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 GetNeighborsRequest implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("GetNeighborsRequest");
  private static final TField SPACE_ID_FIELD_DESC = new TField("space_id", TType.I32, (short)1);
  private static final TField COLUMN_NAMES_FIELD_DESC = new TField("column_names", TType.LIST, (short)2);
  private static final TField PARTS_FIELD_DESC = new TField("parts", TType.MAP, (short)3);
  private static final TField TRAVERSE_SPEC_FIELD_DESC = new TField("traverse_spec", TType.STRUCT, (short)4);
  private static final TField COMMON_FIELD_DESC = new TField("common", TType.STRUCT, (short)5);

  public int space_id;
  public List<byte[]> column_names;
  public Map<Integer,List<com.vesoft.nebula.Value>> parts;
  public TraverseSpec traverse_spec;
  public RequestCommon common;
  public static final int SPACE_ID = 1;
  public static final int COLUMN_NAMES = 2;
  public static final int PARTS = 3;
  public static final int TRAVERSE_SPEC = 4;
  public static final int COMMON = 5;

  // isset id assignments
  private static final int __SPACE_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(SPACE_ID, new FieldMetaData("space_id", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I32)));
    tmpMetaDataMap.put(COLUMN_NAMES, new FieldMetaData("column_names", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new FieldValueMetaData(TType.STRING))));
    tmpMetaDataMap.put(PARTS, new FieldMetaData("parts", TFieldRequirementType.DEFAULT, 
        new MapMetaData(TType.MAP, 
            new FieldValueMetaData(TType.I32), 
            new ListMetaData(TType.LIST, 
                new StructMetaData(TType.STRUCT, com.vesoft.nebula.Value.class)))));
    tmpMetaDataMap.put(TRAVERSE_SPEC, new FieldMetaData("traverse_spec", TFieldRequirementType.DEFAULT, 
        new StructMetaData(TType.STRUCT, TraverseSpec.class)));
    tmpMetaDataMap.put(COMMON, new FieldMetaData("common", TFieldRequirementType.OPTIONAL, 
        new StructMetaData(TType.STRUCT, RequestCommon.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap);
  }

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

  public GetNeighborsRequest() {
  }

  public GetNeighborsRequest(
      int space_id,
      List<byte[]> column_names,
      Map<Integer,List<com.vesoft.nebula.Value>> parts,
      TraverseSpec traverse_spec) {
    this();
    this.space_id = space_id;
    setSpace_idIsSet(true);
    this.column_names = column_names;
    this.parts = parts;
    this.traverse_spec = traverse_spec;
  }

  public GetNeighborsRequest(
      int space_id,
      List<byte[]> column_names,
      Map<Integer,List<com.vesoft.nebula.Value>> parts,
      TraverseSpec traverse_spec,
      RequestCommon common) {
    this();
    this.space_id = space_id;
    setSpace_idIsSet(true);
    this.column_names = column_names;
    this.parts = parts;
    this.traverse_spec = traverse_spec;
    this.common = common;
  }

  public static class Builder {
    private int space_id;
    private List<byte[]> column_names;
    private Map<Integer,List<com.vesoft.nebula.Value>> parts;
    private TraverseSpec traverse_spec;
    private RequestCommon common;

    BitSet __optional_isset = new BitSet(1);

    public Builder() {
    }

    public Builder setSpace_id(final int space_id) {
      this.space_id = space_id;
      __optional_isset.set(__SPACE_ID_ISSET_ID, true);
      return this;
    }

    public Builder setColumn_names(final List<byte[]> column_names) {
      this.column_names = column_names;
      return this;
    }

    public Builder setParts(final Map<Integer,List<com.vesoft.nebula.Value>> parts) {
      this.parts = parts;
      return this;
    }

    public Builder setTraverse_spec(final TraverseSpec traverse_spec) {
      this.traverse_spec = traverse_spec;
      return this;
    }

    public Builder setCommon(final RequestCommon common) {
      this.common = common;
      return this;
    }

    public GetNeighborsRequest build() {
      GetNeighborsRequest result = new GetNeighborsRequest();
      if (__optional_isset.get(__SPACE_ID_ISSET_ID)) {
        result.setSpace_id(this.space_id);
      }
      result.setColumn_names(this.column_names);
      result.setParts(this.parts);
      result.setTraverse_spec(this.traverse_spec);
      result.setCommon(this.common);
      return result;
    }
  }

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

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public GetNeighborsRequest(GetNeighborsRequest other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.space_id = TBaseHelper.deepCopy(other.space_id);
    if (other.isSetColumn_names()) {
      this.column_names = TBaseHelper.deepCopy(other.column_names);
    }
    if (other.isSetParts()) {
      this.parts = TBaseHelper.deepCopy(other.parts);
    }
    if (other.isSetTraverse_spec()) {
      this.traverse_spec = TBaseHelper.deepCopy(other.traverse_spec);
    }
    if (other.isSetCommon()) {
      this.common = TBaseHelper.deepCopy(other.common);
    }
  }

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

  public int getSpace_id() {
    return this.space_id;
  }

  public GetNeighborsRequest setSpace_id(int space_id) {
    this.space_id = space_id;
    setSpace_idIsSet(true);
    return this;
  }

  public void unsetSpace_id() {
    __isset_bit_vector.clear(__SPACE_ID_ISSET_ID);
  }

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

  public void setSpace_idIsSet(boolean __value) {
    __isset_bit_vector.set(__SPACE_ID_ISSET_ID, __value);
  }

  public List<byte[]> getColumn_names() {
    return this.column_names;
  }

  public GetNeighborsRequest setColumn_names(List<byte[]> column_names) {
    this.column_names = column_names;
    return this;
  }

  public void unsetColumn_names() {
    this.column_names = null;
  }

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

  public void setColumn_namesIsSet(boolean __value) {
    if (!__value) {
      this.column_names = null;
    }
  }

  public Map<Integer,List<com.vesoft.nebula.Value>> getParts() {
    return this.parts;
  }

  public GetNeighborsRequest setParts(Map<Integer,List<com.vesoft.nebula.Value>> parts) {
    this.parts = parts;
    return this;
  }

  public void unsetParts() {
    this.parts = null;
  }

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

  public void setPartsIsSet(boolean __value) {
    if (!__value) {
      this.parts = null;
    }
  }

  public TraverseSpec getTraverse_spec() {
    return this.traverse_spec;
  }

  public GetNeighborsRequest setTraverse_spec(TraverseSpec traverse_spec) {
    this.traverse_spec = traverse_spec;
    return this;
  }

  public void unsetTraverse_spec() {
    this.traverse_spec = null;
  }

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

  public void setTraverse_specIsSet(boolean __value) {
    if (!__value) {
      this.traverse_spec = null;
    }
  }

  public RequestCommon getCommon() {
    return this.common;
  }

  public GetNeighborsRequest setCommon(RequestCommon common) {
    this.common = common;
    return this;
  }

  public void unsetCommon() {
    this.common = null;
  }

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

  public void setCommonIsSet(boolean __value) {
    if (!__value) {
      this.common = null;
    }
  }

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

    case COLUMN_NAMES:
      if (__value == null) {
        unsetColumn_names();
      } else {
        setColumn_names((List<byte[]>)__value);
      }
      break;

    case PARTS:
      if (__value == null) {
        unsetParts();
      } else {
        setParts((Map<Integer,List<com.vesoft.nebula.Value>>)__value);
      }
      break;

    case TRAVERSE_SPEC:
      if (__value == null) {
        unsetTraverse_spec();
      } else {
        setTraverse_spec((TraverseSpec)__value);
      }
      break;

    case COMMON:
      if (__value == null) {
        unsetCommon();
      } else {
        setCommon((RequestCommon)__value);
      }
      break;

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

  public Object getFieldValue(int fieldID) {
    switch (fieldID) {
    case SPACE_ID:
      return new Integer(getSpace_id());

    case COLUMN_NAMES:
      return getColumn_names();

    case PARTS:
      return getParts();

    case TRAVERSE_SPEC:
      return getTraverse_spec();

    case COMMON:
      return getCommon();

    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 GetNeighborsRequest))
      return false;
    GetNeighborsRequest that = (GetNeighborsRequest)_that;

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

    if (!TBaseHelper.equalsSlow(this.isSetColumn_names(), that.isSetColumn_names(), this.column_names, that.column_names)) { return false; }

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

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

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

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {space_id, column_names, parts, traverse_spec, common});
  }

  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 SPACE_ID:
          if (__field.type == TType.I32) {
            this.space_id = iprot.readI32();
            setSpace_idIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case COLUMN_NAMES:
          if (__field.type == TType.LIST) {
            {
              TList _list41 = iprot.readListBegin();
              this.column_names = new ArrayList<byte[]>(Math.max(0, _list41.size));
              for (int _i42 = 0; 
                   (_list41.size < 0) ? iprot.peekList() : (_i42 < _list41.size); 
                   ++_i42)
              {
                byte[] _elem43;
                _elem43 = iprot.readBinary();
                this.column_names.add(_elem43);
              }
              iprot.readListEnd();
            }
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case PARTS:
          if (__field.type == TType.MAP) {
            {
              TMap _map44 = iprot.readMapBegin();
              this.parts = new HashMap<Integer,List<com.vesoft.nebula.Value>>(Math.max(0, 2*_map44.size));
              for (int _i45 = 0; 
                   (_map44.size < 0) ? iprot.peekMap() : (_i45 < _map44.size); 
                   ++_i45)
              {
                int _key46;
                List<com.vesoft.nebula.Value> _val47;
                _key46 = iprot.readI32();
                {
                  TList _list48 = iprot.readListBegin();
                  _val47 = new ArrayList<com.vesoft.nebula.Value>(Math.max(0, _list48.size));
                  for (int _i49 = 0; 
                       (_list48.size < 0) ? iprot.peekList() : (_i49 < _list48.size); 
                       ++_i49)
                  {
                    com.vesoft.nebula.Value _elem50;
                    _elem50 = new com.vesoft.nebula.Value();
                    _elem50.read(iprot);
                    _val47.add(_elem50);
                  }
                  iprot.readListEnd();
                }
                this.parts.put(_key46, _val47);
              }
              iprot.readMapEnd();
            }
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case TRAVERSE_SPEC:
          if (__field.type == TType.STRUCT) {
            this.traverse_spec = new TraverseSpec();
            this.traverse_spec.read(iprot);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case COMMON:
          if (__field.type == TType.STRUCT) {
            this.common = new RequestCommon();
            this.common.read(iprot);
          } 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(SPACE_ID_FIELD_DESC);
    oprot.writeI32(this.space_id);
    oprot.writeFieldEnd();
    if (this.column_names != null) {
      oprot.writeFieldBegin(COLUMN_NAMES_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRING, this.column_names.size()));
        for (byte[] _iter51 : this.column_names)        {
          oprot.writeBinary(_iter51);
        }
        oprot.writeListEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.parts != null) {
      oprot.writeFieldBegin(PARTS_FIELD_DESC);
      {
        oprot.writeMapBegin(new TMap(TType.I32, TType.LIST, this.parts.size()));
        for (Map.Entry<Integer, List<com.vesoft.nebula.Value>> _iter52 : this.parts.entrySet())        {
          oprot.writeI32(_iter52.getKey());
          {
            oprot.writeListBegin(new TList(TType.STRUCT, _iter52.getValue().size()));
            for (com.vesoft.nebula.Value _iter53 : _iter52.getValue())            {
              _iter53.write(oprot);
            }
            oprot.writeListEnd();
          }
        }
        oprot.writeMapEnd();
      }
      oprot.writeFieldEnd();
    }
    if (this.traverse_spec != null) {
      oprot.writeFieldBegin(TRAVERSE_SPEC_FIELD_DESC);
      this.traverse_spec.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.common != null) {
      if (isSetCommon()) {
        oprot.writeFieldBegin(COMMON_FIELD_DESC);
        this.common.write(oprot);
        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("GetNeighborsRequest");
    sb.append(space);
    sb.append("(");
    sb.append(newLine);
    boolean first = true;

    sb.append(indentStr);
    sb.append("space_id");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getSpace_id(), indent + 1, prettyPrint));
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("column_names");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getColumn_names() == null) {
      sb.append("null");
    } else {
      sb.append(TBaseHelper.toString(this.getColumn_names(), indent + 1, prettyPrint));
    }
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("parts");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getParts() == null) {
      sb.append("null");
    } else {
      sb.append(TBaseHelper.toString(this.getParts(), indent + 1, prettyPrint));
    }
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("traverse_spec");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getTraverse_spec() == null) {
      sb.append("null");
    } else {
      sb.append(TBaseHelper.toString(this.getTraverse_spec(), indent + 1, prettyPrint));
    }
    first = false;
    if (isSetCommon())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("common");
      sb.append(space);
      sb.append(":").append(space);
      if (this.getCommon() == null) {
        sb.append("null");
      } else {
        sb.append(TBaseHelper.toString(this.getCommon(), 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
  }

}

