/**
 * 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 AdminJobReq implements TBase, java.io.Serializable, Cloneable, Comparable<AdminJobReq> {
  private static final TStruct STRUCT_DESC = new TStruct("AdminJobReq");
  private static final TField SPACE_ID_FIELD_DESC = new TField("space_id", TType.I32, (short)1);
  private static final TField OP_FIELD_DESC = new TField("op", TType.I32, (short)2);
  private static final TField TYPE_FIELD_DESC = new TField("type", TType.I32, (short)3);
  private static final TField PARAS_FIELD_DESC = new TField("paras", TType.LIST, (short)4);

  public int space_id;
  /**
   * 
   * @see JobOp
   */
  public JobOp op;
  /**
   * 
   * @see JobType
   */
  public JobType type;
  public List<byte[]> paras;
  public static final int SPACE_ID = 1;
  public static final int OP = 2;
  public static final int TYPE = 3;
  public static final int PARAS = 4;

  // 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(OP, new FieldMetaData("op", TFieldRequirementType.DEFAULT, 
        new FieldValueMetaData(TType.I32)));
    tmpMetaDataMap.put(TYPE, new FieldMetaData("type", 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(AdminJobReq.class, metaDataMap);
  }

  public AdminJobReq() {
  }

  public AdminJobReq(
      int space_id,
      JobOp op,
      JobType type,
      List<byte[]> paras) {
    this();
    this.space_id = space_id;
    setSpace_idIsSet(true);
    this.op = op;
    this.type = type;
    this.paras = paras;
  }

  public static class Builder {
    private int space_id;
    private JobOp op;
    private JobType type;
    private List<byte[]> paras;

    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 setOp(final JobOp op) {
      this.op = op;
      return this;
    }

    public Builder setType(final JobType type) {
      this.type = type;
      return this;
    }

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

    public AdminJobReq build() {
      AdminJobReq result = new AdminJobReq();
      if (__optional_isset.get(__SPACE_ID_ISSET_ID)) {
        result.setSpace_id(this.space_id);
      }
      result.setOp(this.op);
      result.setType(this.type);
      result.setParas(this.paras);
      return result;
    }
  }

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

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public AdminJobReq(AdminJobReq other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    this.space_id = TBaseHelper.deepCopy(other.space_id);
    if (other.isSetOp()) {
      this.op = TBaseHelper.deepCopy(other.op);
    }
    if (other.isSetType()) {
      this.type = TBaseHelper.deepCopy(other.type);
    }
    if (other.isSetParas()) {
      this.paras = TBaseHelper.deepCopy(other.paras);
    }
  }

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

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

  public AdminJobReq 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);
  }

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

  /**
   * 
   * @see JobOp
   */
  public AdminJobReq setOp(JobOp 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;
    }
  }

  /**
   * 
   * @see JobType
   */
  public JobType getType() {
    return this.type;
  }

  /**
   * 
   * @see JobType
   */
  public AdminJobReq setType(JobType type) {
    this.type = type;
    return this;
  }

  public void unsetType() {
    this.type = null;
  }

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

  public void setTypeIsSet(boolean __value) {
    if (!__value) {
      this.type = null;
    }
  }

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

  public AdminJobReq 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_ID:
      if (__value == null) {
        unsetSpace_id();
      } else {
        setSpace_id((Integer)__value);
      }
      break;

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

    case TYPE:
      if (__value == null) {
        unsetType();
      } else {
        setType((JobType)__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_ID:
      return new Integer(getSpace_id());

    case OP:
      return getOp();

    case TYPE:
      return getType();

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

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

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

    if (!TBaseHelper.equalsNobinary(this.isSetType(), that.isSetType(), this.type, that.type)) { 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_id, op, type, paras});
  }

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

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

    lastComparison = Boolean.valueOf(isSetSpace_id()).compareTo(other.isSetSpace_id());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(space_id, other.space_id);
    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(isSetType()).compareTo(other.isSetType());
    if (lastComparison != 0) {
      return lastComparison;
    }
    lastComparison = TBaseHelper.compareTo(type, other.type);
    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_ID:
          if (__field.type == TType.I32) {
            this.space_id = iprot.readI32();
            setSpace_idIsSet(true);
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case OP:
          if (__field.type == TType.I32) {
            this.op = JobOp.findByValue(iprot.readI32());
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case TYPE:
          if (__field.type == TType.I32) {
            this.type = JobType.findByValue(iprot.readI32());
          } else { 
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case PARAS:
          if (__field.type == TType.LIST) {
            {
              TList _list34 = iprot.readListBegin();
              this.paras = new ArrayList<byte[]>(Math.max(0, _list34.size));
              for (int _i35 = 0; 
                   (_list34.size < 0) ? iprot.peekList() : (_i35 < _list34.size); 
                   ++_i35)
              {
                byte[] _elem36;
                _elem36 = iprot.readBinary();
                this.paras.add(_elem36);
              }
              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(SPACE_ID_FIELD_DESC);
    oprot.writeI32(this.space_id);
    oprot.writeFieldEnd();
    if (this.op != null) {
      oprot.writeFieldBegin(OP_FIELD_DESC);
      oprot.writeI32(this.op == null ? 0 : this.op.getValue());
      oprot.writeFieldEnd();
    }
    if (this.type != null) {
      oprot.writeFieldBegin(TYPE_FIELD_DESC);
      oprot.writeI32(this.type == null ? 0 : this.type.getValue());
      oprot.writeFieldEnd();
    }
    if (this.paras != null) {
      oprot.writeFieldBegin(PARAS_FIELD_DESC);
      {
        oprot.writeListBegin(new TList(TType.STRING, this.paras.size()));
        for (byte[] _iter37 : this.paras)        {
          oprot.writeBinary(_iter37);
        }
        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("AdminJobReq");
    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("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("type");
    sb.append(space);
    sb.append(":").append(space);
    if (this.getType() == null) {
      sb.append("null");
    } else {
      String type_name = this.getType() == null ? "null" : this.getType().name();
      if (type_name != null) {
        sb.append(type_name);
        sb.append(" (");
      }
      sb.append(this.getType());
      if (type_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
  }

}

