/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
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 RecursiveStruct implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("RecursiveStruct");
  private static final TField MES_FIELD_DESC = new TField("mes", TType.LIST, (short)1);

  public final List<RecursiveStruct> mes;
  public static final int MES = 1;

  public RecursiveStruct(
      List<RecursiveStruct> mes) {
    this.mes = mes;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public RecursiveStruct(RecursiveStruct other) {
    if (other.isSetMes()) {
      this.mes = TBaseHelper.deepCopy(other.mes);
    } else {
      this.mes = null;
    }
  }

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

  public List<RecursiveStruct> getMes() {
    return this.mes;
  }

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

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

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

    return true;
  }

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

  // This is required to satisfy the TBase interface, but can't be implemented on immutable struture.
  public void read(TProtocol iprot) throws TException {
    throw new TException("unimplemented in android immutable structure");
  }

  public static RecursiveStruct deserialize(TProtocol iprot) throws TException {
    List<RecursiveStruct> tmp_mes = null;
    TField __field;
    iprot.readStructBegin();
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) {
        break;
      }
      switch (__field.id)
      {
        case MES:
          if (__field.type == TType.LIST) {
            {
              TList _list12 = iprot.readListBegin();
              tmp_mes = new ArrayList<RecursiveStruct>(Math.max(0, _list12.size));
              for (int _i13 = 0; 
                   (_list12.size < 0) ? iprot.peekList() : (_i13 < _list12.size); 
                   ++_i13)
              {
                RecursiveStruct _elem14;
                _elem14 = RecursiveStruct.deserialize(iprot);
                tmp_mes.add(_elem14);
              }
              iprot.readListEnd();
            }
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    RecursiveStruct _that;
    _that = new RecursiveStruct(
      tmp_mes
    );
    _that.validate();
    return _that;
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.mes != null) {
      if (isSetMes()) {
        oprot.writeFieldBegin(MES_FIELD_DESC);
        {
          oprot.writeListBegin(new TList(TType.STRUCT, this.mes.size()));
          for (RecursiveStruct _iter15 : this.mes)          {
            _iter15.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) {
    return TBaseHelper.toStringHelper(this, indent, prettyPrint);
  }

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

}

