/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package test.fixtures.adapter;

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 CountingStruct implements TBase, java.io.Serializable, Cloneable {
  private static final TStruct STRUCT_DESC = new TStruct("CountingStruct");
  private static final TField REGULAR_INT_FIELD_DESC = new TField("regularInt", TType.I64, (short)1);
  private static final TField COUNTING_INT_FIELD_DESC = new TField("countingInt", TType.I64, (short)2);
  private static final TField REGULAR_STRING_FIELD_DESC = new TField("regularString", TType.STRING, (short)3);

  public final Long regularInt;
  public final Long countingInt;
  public final String regularString;
  public static final int REGULARINT = 1;
  public static final int COUNTINGINT = 2;
  public static final int REGULARSTRING = 3;

  public CountingStruct(
      Long regularInt,
      Long countingInt,
      String regularString) {
    this.regularInt = regularInt;
    this.countingInt = countingInt;
    this.regularString = regularString;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public CountingStruct(CountingStruct other) {
    if (other.isSetRegularInt()) {
      this.regularInt = TBaseHelper.deepCopy(other.regularInt);
    } else {
      this.regularInt = null;
    }
    if (other.isSetCountingInt()) {
      this.countingInt = TBaseHelper.deepCopy(other.countingInt);
    } else {
      this.countingInt = null;
    }
    if (other.isSetRegularString()) {
      this.regularString = TBaseHelper.deepCopy(other.regularString);
    } else {
      this.regularString = null;
    }
  }

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

  public Long getRegularInt() {
    return this.regularInt;
  }

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

  public Long getCountingInt() {
    return this.countingInt;
  }

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

  public String getRegularString() {
    return this.regularString;
  }

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

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

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

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

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

    return true;
  }

  @Override
  public int hashCode() {
    return Arrays.deepHashCode(new Object[] {regularInt, countingInt, regularString});
  }

  // 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 CountingStruct deserialize(TProtocol iprot) throws TException {
    Long tmp_regularInt = null;
    Long tmp_countingInt = null;
    String tmp_regularString = null;
    TField __field;
    iprot.readStructBegin();
    while (true)
    {
      __field = iprot.readFieldBegin();
      if (__field.type == TType.STOP) {
        break;
      }
      switch (__field.id)
      {
        case REGULARINT:
          if (__field.type == TType.I64) {
            tmp_regularInt = iprot.readI64();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case COUNTINGINT:
          if (__field.type == TType.I64) {
            tmp_countingInt = iprot.readI64();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        case REGULARSTRING:
          if (__field.type == TType.STRING) {
            tmp_regularString = iprot.readString();
          } else {
            TProtocolUtil.skip(iprot, __field.type);
          }
          break;
        default:
          TProtocolUtil.skip(iprot, __field.type);
          break;
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    CountingStruct _that;
    _that = new CountingStruct(
      tmp_regularInt
      ,tmp_countingInt
      ,tmp_regularString
    );
    _that.validate();
    return _that;
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.regularInt != null) {
      if (isSetRegularInt()) {
        oprot.writeFieldBegin(REGULAR_INT_FIELD_DESC);
        oprot.writeI64(this.regularInt);
        oprot.writeFieldEnd();
      }
    }
    if (this.countingInt != null) {
      if (isSetCountingInt()) {
        oprot.writeFieldBegin(COUNTING_INT_FIELD_DESC);
        oprot.writeI64(this.countingInt);
        oprot.writeFieldEnd();
      }
    }
    if (this.regularString != null) {
      if (isSetRegularString()) {
        oprot.writeFieldBegin(REGULAR_STRING_FIELD_DESC);
        oprot.writeString(this.regularString);
        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
  }

}

