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

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 AlterSpaceReq implements TBase, java.io.Serializable, Cloneable, Comparable<AlterSpaceReq> {
  private static final TStruct STRUCT_DESC = new TStruct("AlterSpaceReq");
  private static final TField SPACE_NAME_FIELD_DESC = new TField("space_name", TType.STRING, (short)1);
  private static final TField OP_FIELD_DESC = new TField("op", TType.I32, (short)2);
  private static final TField PARAS_FIELD_DESC = new TField("paras", TType.LIST, (short)3);

  public byte[] space_name;
  /**
   * 
   * @see AlterSpaceOp
   */
  public AlterSpaceOp op;
  public List<byte[]> paras;
  public static final int SPACE_NAME = 1;
  public static final int OP = 2;
  public static final int PARAS = 3;

  // isset id assignments

  public static final Map<Integer, FieldMetaData> metaDataMap;

  static {
    Map<Integer, FieldMetaData> tmpMetaDataMap = new HashMap<Integer, FieldMetaData>();
    tmpMetaDataMap.put(SPACE_NAME, new FieldMetaData("space_name", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.STRING)));
    tmpMetaDataMap.put(OP, new FieldMetaData("op", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I32)));
    tmpMetaDataMap.put(PARAS, new FieldMetaData("paras", TFieldRequirementType.DEFAULT, 
        new ListMetaData(TType.LIST, 
            new FieldValueMetaData(TType.STRING))));
    metaDataMap = Collections.unmodifiableMap(tmpMetaDataMap);
  }

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

  public AlterSpaceReq() {
  }

  public AlterSpaceReq(
      byte[] space_name,
      AlterSpaceOp op,
      List<byte[]> paras) {
    this();
    this.space_name = space_name;
    this.op = op;
    this.paras = paras;
  }

  public static class Builder {
    private byte[] space_name;
    private AlterSpaceOp op;
    private List<byte[]> paras;

    public Builder() {
    }

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

    public Builder setOp(final AlterSpaceOp op) {
      this.op = op;
      return this;
    }

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

    public AlterSpaceReq build() {
      AlterSpaceReq result = new AlterSpaceReq();
      result.setSpace_name(this.space_name);
      result.setOp(this.op);
      result.setParas(this.paras);
      return result;
    }
  }

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

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public AlterSpaceReq(AlterSpaceReq other) {
    if (other.isSetSpace_name()) {
      this.space_name = TBaseHelper.deepCopy(other.space_name);
    }
    if (other.isSetOp()) {
      this.op = TBaseHelper.deepCopy(other.op);
    }
    if (other.isSetParas()) {
      this.paras = TBaseHelper.deepCopy(other.paras);
    }
  }

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

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

  public AlterSpaceReq 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;
    }
  }

  /**
   * 
   * @see AlterSpaceOp
   */
  public AlterSpaceOp getOp() {
    return this.op;
  }

  /**
   * 
   * @see AlterSpaceOp
   */
  public AlterSpaceReq setOp(AlterSpaceOp op) {
    this.op = op;
    return this;
  }

  public void unsetOp() {
    this.op = null;
  }

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

  public void setOpIsSet(boolean __value) {
    if (!__value) {
      this.op = null;
    }
  }

  public List<byte[]> getParas() {
    return this.paras;
  }

  public AlterSpaceReq setParas(List<byte[]> paras) {
    this.paras = paras;
    return this;
  }

  public void unsetParas() {
    this.paras = null;
  }

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

  public void setParasIsSet(boolean __value) {
    if (!__value) {
      this.paras = null;
    }
  }

  @SuppressWarnings("unchecked")
  public void setFieldValue(int fieldID, Object __value) {
    switch (fieldID) {
    case SPACE_NAME:
      if (__value == null) {
        unsetSpace_name();
      } else {
        setSpace_name((byte[])__value);
      }
      break;

    case OP:
      if (__value == null) {
        unsetOp();
      } else {
        setOp((AlterSpaceOp)__value);
      }
      break;

    case PARAS:
      if (__value == null) {
        unsetParas();
      } else {
        setParas((List<byte[]>)__value);
      }
      break;

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

  public Object getFieldValue(int fieldID) {
    switch (fieldID) {
    case SPACE_NAME:
      return getSpace_name();

    case OP:
      return getOp();

    case PARAS:
      return getParas();

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

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

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

    if (!TBaseHelper.equalsSlow(this.isSetParas(), that.isSetParas(), this.paras, that.paras)) { return false; }

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {space_name, op, paras});
  }

  @Override
  public int compareTo(AlterSpaceReq other) {
    if (other == null) {
      // See java.lang.Comparable docs
      throw new NullPointerException();
    }

    if (other == this) {
      return 0;
    }
    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetSpace_name()).compareTo(other.isSetSpace_name());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(space_name, other.space_name);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetOp()).compareTo(other.isSetOp());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(op, other.op);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    lastComparison = Boolean.valueOf(isSetParas()).compareTo(other.isSetParas());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(paras, other.paras);
    if (lastComparison != 0) { 
      return lastComparison;
    }
    return 0;
  }

  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_NAME:
          if (__field.type == TType.STRING) {
            this.space_name = iprot.readBinary();
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case OP:
          if (__field.type == TType.I32) {
            this.op = AlterSpaceOp.findByValue(iprot.readI32());
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case PARAS:
          if (__field.type == TType.LIST) {
            {
              TList _list30 = iprot.readListBegin();
              this.paras = new ArrayList<byte[]>(Math.max(0, _list30.size));
              for (int _i31 = 0; 
                   (_list30.size < 0) ? iprot.peekList() : (_i31 < _list30.size); 
                   ++_i31)
              {
                byte[] _elem32;
                _elem32 = iprot.readBinary();
                this.paras.add(_elem32);
              }
              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);
    if (this.space_name != null) {
      oprot.writeFieldBegin(SPACE_NAME_FIELD_DESC);
      oprot.writeBinary(this.space_name);
      oprot.writeFieldEnd();
    }
    if (this.op != null) {
      oprot.writeFieldBegin(OP_FIELD_DESC);
      oprot.writeI32(this.op == null ? 0 : this.op.getValue());
      oprot.writeFieldEnd();
    }
    if (this.paras != null) {
      oprot.writeFieldBegin(PARAS_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRING, this.paras.size()));
        for (byte[] _iter33 : this.paras)        {
          oprot.writeBinary(_iter33);
        }
        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("AlterSpaceReq");
    sb.append(space);
    sb.append("(");
    sb.append(newLine);
    boolean first = true;

    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 (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("op");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getOp() == null) {
      sb.append("null");
    } else {
      String op_name = this.getOp() == null ? "null" : this.getOp().name();
      if (op_name != null) {
        sb.append(op_name);
        sb.append(" (");
      }
      sb.append(this.getOp());
      if (op_name != null) {
        sb.append(")");
      }
    }
    first = false;
    if (!first) sb.append("," + newLine);
    sb.append(indentStr);
    sb.append("paras");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getParas() == null) {
      sb.append("null");
    } else {
      sb.append(TBaseHelper.toString(this.getParas(), 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
  }

}

