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

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 ExecutionResponse implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("ExecutionResponse");
  private static final TField ERROR_CODE_FIELD_DESC = new TField("error_code", TType.I32, (short)1);
  private static final TField LATENCY_IN_US_FIELD_DESC = new TField("latency_in_us", TType.I64, (short)2);
  private static final TField DATA_FIELD_DESC = new TField("data", TType.STRUCT, (short)3);
  private static final TField SPACE_NAME_FIELD_DESC = new TField("space_name", TType.STRING, (short)4);
  private static final TField ERROR_MSG_FIELD_DESC = new TField("error_msg", TType.STRING, (short)5);
  private static final TField PLAN_DESC_FIELD_DESC = new TField("plan_desc", TType.STRUCT, (short)6);
  private static final TField COMMENT_FIELD_DESC = new TField("comment", TType.STRING, (short)7);

  /**
   * 
   * @see com.vesoft.nebula.ErrorCode
   */
  public com.vesoft.nebula.ErrorCode error_code;
  public long latency_in_us;
  public com.vesoft.nebula.DataSet data;
  public byte[] space_name;
  public byte[] error_msg;
  public PlanDescription plan_desc;
  public byte[] comment;
  public static final int ERROR_CODE = 1;
  public static final int LATENCY_IN_US = 2;
  public static final int DATA = 3;
  public static final int SPACE_NAME = 4;
  public static final int ERROR_MSG = 5;
  public static final int PLAN_DESC = 6;
  public static final int COMMENT = 7;

  // isset id assignments
  private static final int __LATENCY_IN_US_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(ERROR_CODE, new FieldMetaData("error_code", TFieldRequirementType.REQUIRED, 
        new FieldValueMetaData(TType.I32)));
    tmpMetaDataMap.put(LATENCY_IN_US, new FieldMetaData("latency_in_us", TFieldRequirementType.REQUIRED, 
        new FieldValueMetaData(TType.I64)));
    tmpMetaDataMap.put(DATA, new FieldMetaData("data", TFieldRequirementType.OPTIONAL, 
        new StructMetaData(TType.STRUCT, com.vesoft.nebula.DataSet.class)));
    tmpMetaDataMap.put(SPACE_NAME, new FieldMetaData("space_name", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.STRING)));
    tmpMetaDataMap.put(ERROR_MSG, new FieldMetaData("error_msg", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.STRING)));
    tmpMetaDataMap.put(PLAN_DESC, new FieldMetaData("plan_desc", TFieldRequirementType.OPTIONAL, 
        new StructMetaData(TType.STRUCT, PlanDescription.class)));
    tmpMetaDataMap.put(COMMENT, new FieldMetaData("comment", TFieldRequirementType.OPTIONAL, 
        new FieldValueMetaData(TType.STRING)));
    metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap);
  }

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

  public ExecutionResponse() {
  }

  public ExecutionResponse(
      com.vesoft.nebula.ErrorCode error_code,
      long latency_in_us) {
    this();
    this.error_code = error_code;
    this.latency_in_us = latency_in_us;
    setLatency_in_usIsSet(true);
  }

  public ExecutionResponse(
      com.vesoft.nebula.ErrorCode error_code,
      long latency_in_us,
      com.vesoft.nebula.DataSet data,
      byte[] space_name,
      byte[] error_msg,
      PlanDescription plan_desc,
      byte[] comment) {
    this();
    this.error_code = error_code;
    this.latency_in_us = latency_in_us;
    setLatency_in_usIsSet(true);
    this.data = data;
    this.space_name = space_name;
    this.error_msg = error_msg;
    this.plan_desc = plan_desc;
    this.comment = comment;
  }

  public static class Builder {
    private com.vesoft.nebula.ErrorCode error_code;
    private long latency_in_us;
    private com.vesoft.nebula.DataSet data;
    private byte[] space_name;
    private byte[] error_msg;
    private PlanDescription plan_desc;
    private byte[] comment;

    BitSet __optional_isset = new BitSet(1);

    public Builder() {
    }

    public Builder setError_code(final com.vesoft.nebula.ErrorCode error_code) {
      this.error_code = error_code;
      return this;
    }

    public Builder setLatency_in_us(final long latency_in_us) {
      this.latency_in_us = latency_in_us;
      __optional_isset.set(__LATENCY_IN_US_ISSET_ID, true);
      return this;
    }

    public Builder setData(final com.vesoft.nebula.DataSet data) {
      this.data = data;
      return this;
    }

    public Builder setSpace_name(final byte[] space_name) {
      this.space_name = space_name;
      return this;
    }

    public Builder setError_msg(final byte[] error_msg) {
      this.error_msg = error_msg;
      return this;
    }

    public Builder setPlan_desc(final PlanDescription plan_desc) {
      this.plan_desc = plan_desc;
      return this;
    }

    public Builder setComment(final byte[] comment) {
      this.comment = comment;
      return this;
    }

    public ExecutionResponse build() {
      ExecutionResponse result = new ExecutionResponse();
      result.setError_code(this.error_code);
      if (__optional_isset.get(__LATENCY_IN_US_ISSET_ID)) {
        result.setLatency_in_us(this.latency_in_us);
      }
      result.setData(this.data);
      result.setSpace_name(this.space_name);
      result.setError_msg(this.error_msg);
      result.setPlan_desc(this.plan_desc);
      result.setComment(this.comment);
      return result;
    }
  }

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

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public ExecutionResponse(ExecutionResponse other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetError_code()) {
      this.error_code = TBaseHelper.deepCopy(other.error_code);
    }
    this.latency_in_us = TBaseHelper.deepCopy(other.latency_in_us);
    if (other.isSetData()) {
      this.data = TBaseHelper.deepCopy(other.data);
    }
    if (other.isSetSpace_name()) {
      this.space_name = TBaseHelper.deepCopy(other.space_name);
    }
    if (other.isSetError_msg()) {
      this.error_msg = TBaseHelper.deepCopy(other.error_msg);
    }
    if (other.isSetPlan_desc()) {
      this.plan_desc = TBaseHelper.deepCopy(other.plan_desc);
    }
    if (other.isSetComment()) {
      this.comment = TBaseHelper.deepCopy(other.comment);
    }
  }

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

  /**
   * 
   * @see com.vesoft.nebula.ErrorCode
   */
  public com.vesoft.nebula.ErrorCode getError_code() {
    return this.error_code;
  }

  /**
   * 
   * @see com.vesoft.nebula.ErrorCode
   */
  public ExecutionResponse setError_code(com.vesoft.nebula.ErrorCode error_code) {
    this.error_code = error_code;
    return this;
  }

  public void unsetError_code() {
    this.error_code = null;
  }

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

  public void setError_codeIsSet(boolean __value) {
    if (!__value) {
      this.error_code = null;
    }
  }

  public long getLatency_in_us() {
    return this.latency_in_us;
  }

  public ExecutionResponse setLatency_in_us(long latency_in_us) {
    this.latency_in_us = latency_in_us;
    setLatency_in_usIsSet(true);
    return this;
  }

  public void unsetLatency_in_us() {
    __isset_bit_vector.clear(__LATENCY_IN_US_ISSET_ID);
  }

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

  public void setLatency_in_usIsSet(boolean __value) {
    __isset_bit_vector.set(__LATENCY_IN_US_ISSET_ID, __value);
  }

  public com.vesoft.nebula.DataSet getData() {
    return this.data;
  }

  public ExecutionResponse setData(com.vesoft.nebula.DataSet data) {
    this.data = data;
    return this;
  }

  public void unsetData() {
    this.data = null;
  }

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

  public void setDataIsSet(boolean __value) {
    if (!__value) {
      this.data = null;
    }
  }

  public byte[] getSpace_name() {
    return this.space_name;
  }

  public ExecutionResponse setSpace_name(byte[] space_name) {
    this.space_name = space_name;
    return this;
  }

  public void unsetSpace_name() {
    this.space_name = null;
  }

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

  public void setSpace_nameIsSet(boolean __value) {
    if (!__value) {
      this.space_name = null;
    }
  }

  public byte[] getError_msg() {
    return this.error_msg;
  }

  public ExecutionResponse setError_msg(byte[] error_msg) {
    this.error_msg = error_msg;
    return this;
  }

  public void unsetError_msg() {
    this.error_msg = null;
  }

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

  public void setError_msgIsSet(boolean __value) {
    if (!__value) {
      this.error_msg = null;
    }
  }

  public PlanDescription getPlan_desc() {
    return this.plan_desc;
  }

  public ExecutionResponse setPlan_desc(PlanDescription plan_desc) {
    this.plan_desc = plan_desc;
    return this;
  }

  public void unsetPlan_desc() {
    this.plan_desc = null;
  }

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

  public void setPlan_descIsSet(boolean __value) {
    if (!__value) {
      this.plan_desc = null;
    }
  }

  public byte[] getComment() {
    return this.comment;
  }

  public ExecutionResponse setComment(byte[] comment) {
    this.comment = comment;
    return this;
  }

  public void unsetComment() {
    this.comment = null;
  }

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

  public void setCommentIsSet(boolean __value) {
    if (!__value) {
      this.comment = null;
    }
  }

  public void setFieldValue(int fieldID, Object __value) {
    switch (fieldID) {
    case ERROR_CODE:
      if (__value == null) {
        unsetError_code();
      } else {
        setError_code((com.vesoft.nebula.ErrorCode)__value);
      }
      break;

    case LATENCY_IN_US:
      if (__value == null) {
        unsetLatency_in_us();
      } else {
        setLatency_in_us((Long)__value);
      }
      break;

    case DATA:
      if (__value == null) {
        unsetData();
      } else {
        setData((com.vesoft.nebula.DataSet)__value);
      }
      break;

    case SPACE_NAME:
      if (__value == null) {
        unsetSpace_name();
      } else {
        setSpace_name((byte[])__value);
      }
      break;

    case ERROR_MSG:
      if (__value == null) {
        unsetError_msg();
      } else {
        setError_msg((byte[])__value);
      }
      break;

    case PLAN_DESC:
      if (__value == null) {
        unsetPlan_desc();
      } else {
        setPlan_desc((PlanDescription)__value);
      }
      break;

    case COMMENT:
      if (__value == null) {
        unsetComment();
      } else {
        setComment((byte[])__value);
      }
      break;

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

  public Object getFieldValue(int fieldID) {
    switch (fieldID) {
    case ERROR_CODE:
      return getError_code();

    case LATENCY_IN_US:
      return new Long(getLatency_in_us());

    case DATA:
      return getData();

    case SPACE_NAME:
      return getSpace_name();

    case ERROR_MSG:
      return getError_msg();

    case PLAN_DESC:
      return getPlan_desc();

    case COMMENT:
      return getComment();

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

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

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

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

    if (!TBaseHelper.equalsSlow(this.isSetSpace_name(), that.isSetSpace_name(), this.space_name, that.space_name)) { return false; }

    if (!TBaseHelper.equalsSlow(this.isSetError_msg(), that.isSetError_msg(), this.error_msg, that.error_msg)) { return false; }

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

    if (!TBaseHelper.equalsSlow(this.isSetComment(), that.isSetComment(), this.comment, that.comment)) { return false; }

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {error_code, latency_in_us, data, space_name, error_msg, plan_desc, comment});
  }

  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 ERROR_CODE:
          if (__field.type == TType.I32) {
            this.error_code = com.vesoft.nebula.ErrorCode.findByValue(iprot.readI32());
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case LATENCY_IN_US:
          if (__field.type == TType.I64) {
            this.latency_in_us = iprot.readI64();
            setLatency_in_usIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case DATA:
          if (__field.type == TType.STRUCT) {
            this.data = new com.vesoft.nebula.DataSet();
            this.data.read(iprot);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case SPACE_NAME:
          if (__field.type == TType.STRING) {
            this.space_name = iprot.readBinary();
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case ERROR_MSG:
          if (__field.type == TType.STRING) {
            this.error_msg = iprot.readBinary();
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case PLAN_DESC:
          if (__field.type == TType.STRUCT) {
            this.plan_desc = new PlanDescription();
            this.plan_desc.read(iprot);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case COMMENT:
          if (__field.type == TType.STRING) {
            this.comment = iprot.readBinary();
          } 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
    if (!isSetLatency_in_us()) {
      throw new TProtocolException("Required field 'latency_in_us' was not found in serialized data! Struct: " + toString());
    }
    validate();
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.error_code != null) {
      oprot.writeFieldBegin(ERROR_CODE_FIELD_DESC);
      oprot.writeI32(this.error_code == null ? 0 : this.error_code.getValue());
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(LATENCY_IN_US_FIELD_DESC);
    oprot.writeI64(this.latency_in_us);
    oprot.writeFieldEnd();
    if (this.data != null) {
      if (isSetData()) {
        oprot.writeFieldBegin(DATA_FIELD_DESC);
        this.data.write(oprot);
        oprot.writeFieldEnd();
      }
    }
    if (this.space_name != null) {
      if (isSetSpace_name()) {
        oprot.writeFieldBegin(SPACE_NAME_FIELD_DESC);
        oprot.writeBinary(this.space_name);
        oprot.writeFieldEnd();
      }
    }
    if (this.error_msg != null) {
      if (isSetError_msg()) {
        oprot.writeFieldBegin(ERROR_MSG_FIELD_DESC);
        oprot.writeBinary(this.error_msg);
        oprot.writeFieldEnd();
      }
    }
    if (this.plan_desc != null) {
      if (isSetPlan_desc()) {
        oprot.writeFieldBegin(PLAN_DESC_FIELD_DESC);
        this.plan_desc.write(oprot);
        oprot.writeFieldEnd();
      }
    }
    if (this.comment != null) {
      if (isSetComment()) {
        oprot.writeFieldBegin(COMMENT_FIELD_DESC);
        oprot.writeBinary(this.comment);
        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("ExecutionResponse");
    sb.append(space);
    sb.append("(");
    sb.append(newLine);
    boolean first = true;

    sb.append(indentStr);
    sb.append("error_code");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getError_code() == null) {
      sb.append("null");
    } else {
      String error_code_name = this.getError_code() == null ? "null" : this.getError_code().name();
      if (error_code_name != null) {
        sb.append(error_code_name);
        sb.append(" (");
      }
      sb.append(this.getError_code());
      if (error_code_name != null) {
        sb.append(")");
      }
    }
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("latency_in_us");
    sb.append(space);
    sb.append(":").append(space);
    sb.append(TBaseHelper.toString(this.getLatency_in_us(), indent + 1, prettyPrint));
    first = false;
    if (isSetData())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("data");
      sb.append(space);
      sb.append(":").append(space);
      if (this.getData() == null) {
        sb.append("null");
      } else {
        sb.append(TBaseHelper.toString(this.getData(), indent + 1, prettyPrint));
      }
      first = false;
    }
    if (isSetSpace_name())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("space_name");
      sb.append(space);
      sb.append(":").append(space);
      if (this.getSpace_name() == null) {
        sb.append("null");
      } else {
          int __space_name_size = Math.min(this.getSpace_name().length, 128);
          for (int i = 0; i < __space_name_size; i++) {
            if (i != 0) sb.append(" ");
            sb.append(Integer.toHexString(this.getSpace_name()[i]).length() > 1 ? Integer.toHexString(this.getSpace_name()[i]).substring(Integer.toHexString(this.getSpace_name()[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.getSpace_name()[i]).toUpperCase());
          }
          if (this.getSpace_name().length > 128) sb.append(" ...");
      }
      first = false;
    }
    if (isSetError_msg())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("error_msg");
      sb.append(space);
      sb.append(":").append(space);
      if (this.getError_msg() == null) {
        sb.append("null");
      } else {
          int __error_msg_size = Math.min(this.getError_msg().length, 128);
          for (int i = 0; i < __error_msg_size; i++) {
            if (i != 0) sb.append(" ");
            sb.append(Integer.toHexString(this.getError_msg()[i]).length() > 1 ? Integer.toHexString(this.getError_msg()[i]).substring(Integer.toHexString(this.getError_msg()[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.getError_msg()[i]).toUpperCase());
          }
          if (this.getError_msg().length > 128) sb.append(" ...");
      }
      first = false;
    }
    if (isSetPlan_desc())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("plan_desc");
      sb.append(space);
      sb.append(":").append(space);
      if (this.getPlan_desc() == null) {
        sb.append("null");
      } else {
        sb.append(TBaseHelper.toString(this.getPlan_desc(), indent + 1, prettyPrint));
      }
      first = false;
    }
    if (isSetComment())
    {
      if (!first) sb.append("," + newLine);
      sb.append(indentStr);
      sb.append("comment");
      sb.append(space);
      sb.append(":").append(space);
      if (this.getComment() == null) {
        sb.append("null");
      } else {
          int __comment_size = Math.min(this.getComment().length, 128);
          for (int i = 0; i < __comment_size; i++) {
            if (i != 0) sb.append(" ");
            sb.append(Integer.toHexString(this.getComment()[i]).length() > 1 ? Integer.toHexString(this.getComment()[i]).substring(Integer.toHexString(this.getComment()[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.getComment()[i]).toUpperCase());
          }
          if (this.getComment().length > 128) sb.append(" ...");
      }
      first = false;
    }
    sb.append(newLine + TBaseHelper.reduceIndent(indentStr));
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws TException {
    // check for required fields
    if (error_code == null) {
      throw new TProtocolException(TProtocolException.MISSING_REQUIRED_FIELD, "Required field 'error_code' was not present! Struct: " + toString());
    }
    // alas, we cannot check 'latency_in_us' because it's a primitive and you chose the non-beans generator.
  }

}

