/**
 * Autogenerated by Thrift Compiler (1.0.0-dev)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package AgentVsAgent;

import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;

import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RoundResult implements org.apache.thrift.TBase<RoundResult, RoundResult._Fields>, java.io.Serializable, Cloneable, Comparable<RoundResult> {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RoundResult");

  private static final org.apache.thrift.protocol.TField NORTH_FIELD_DESC = new org.apache.thrift.protocol.TField("north", org.apache.thrift.protocol.TType.I32, (short)1);
  private static final org.apache.thrift.protocol.TField EAST_FIELD_DESC = new org.apache.thrift.protocol.TField("east", org.apache.thrift.protocol.TType.I32, (short)2);
  private static final org.apache.thrift.protocol.TField SOUTH_FIELD_DESC = new org.apache.thrift.protocol.TField("south", org.apache.thrift.protocol.TType.I32, (short)3);
  private static final org.apache.thrift.protocol.TField WEST_FIELD_DESC = new org.apache.thrift.protocol.TField("west", org.apache.thrift.protocol.TType.I32, (short)4);
  private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.I32, (short)5);

  private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
  static {
    schemes.put(StandardScheme.class, new RoundResultStandardSchemeFactory());
    schemes.put(TupleScheme.class, new RoundResultTupleSchemeFactory());
  }

  public int north; // required
  public int east; // required
  public int south; // required
  public int west; // required
  /**
   * 
   * @see GameStatus
   */
  public GameStatus status; // required

  /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
  public enum _Fields implements org.apache.thrift.TFieldIdEnum {
    NORTH((short)1, "north"),
    EAST((short)2, "east"),
    SOUTH((short)3, "south"),
    WEST((short)4, "west"),
    /**
     * 
     * @see GameStatus
     */
    STATUS((short)5, "status");

    private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

    static {
      for (_Fields field : EnumSet.allOf(_Fields.class)) {
        byName.put(field.getFieldName(), field);
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, or null if its not found.
     */
    public static _Fields findByThriftId(int fieldId) {
      switch(fieldId) {
        case 1: // NORTH
          return NORTH;
        case 2: // EAST
          return EAST;
        case 3: // SOUTH
          return SOUTH;
        case 4: // WEST
          return WEST;
        case 5: // STATUS
          return STATUS;
        default:
          return null;
      }
    }

    /**
     * Find the _Fields constant that matches fieldId, throwing an exception
     * if it is not found.
     */
    public static _Fields findByThriftIdOrThrow(int fieldId) {
      _Fields fields = findByThriftId(fieldId);
      if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
      return fields;
    }

    /**
     * Find the _Fields constant that matches name, or null if its not found.
     */
    public static _Fields findByName(String name) {
      return byName.get(name);
    }

    private final short _thriftId;
    private final String _fieldName;

    _Fields(short thriftId, String fieldName) {
      _thriftId = thriftId;
      _fieldName = fieldName;
    }

    public short getThriftFieldId() {
      return _thriftId;
    }

    public String getFieldName() {
      return _fieldName;
    }
  }

  // isset id assignments
  private static final int __NORTH_ISSET_ID = 0;
  private static final int __EAST_ISSET_ID = 1;
  private static final int __SOUTH_ISSET_ID = 2;
  private static final int __WEST_ISSET_ID = 3;
  private byte __isset_bitfield = 0;
  public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
  static {
    Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
    tmpMap.put(_Fields.NORTH, new org.apache.thrift.meta_data.FieldMetaData("north", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32        , "Score")));
    tmpMap.put(_Fields.EAST, new org.apache.thrift.meta_data.FieldMetaData("east", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32        , "Score")));
    tmpMap.put(_Fields.SOUTH, new org.apache.thrift.meta_data.FieldMetaData("south", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32        , "Score")));
    tmpMap.put(_Fields.WEST, new org.apache.thrift.meta_data.FieldMetaData("west", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32        , "Score")));
    tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, GameStatus.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(RoundResult.class, metaDataMap);
  }

  public RoundResult() {
  }

  public RoundResult(
    int north,
    int east,
    int south,
    int west,
    GameStatus status)
  {
    this();
    this.north = north;
    setNorthIsSet(true);
    this.east = east;
    setEastIsSet(true);
    this.south = south;
    setSouthIsSet(true);
    this.west = west;
    setWestIsSet(true);
    this.status = status;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public RoundResult(RoundResult other) {
    __isset_bitfield = other.__isset_bitfield;
    this.north = other.north;
    this.east = other.east;
    this.south = other.south;
    this.west = other.west;
    if (other.isSetStatus()) {
      this.status = other.status;
    }
  }

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

  @Override
  public void clear() {
    setNorthIsSet(false);
    this.north = 0;
    setEastIsSet(false);
    this.east = 0;
    setSouthIsSet(false);
    this.south = 0;
    setWestIsSet(false);
    this.west = 0;
    this.status = null;
  }

  public int getNorth() {
    return this.north;
  }

  public RoundResult setNorth(int north) {
    this.north = north;
    setNorthIsSet(true);
    return this;
  }

  public void unsetNorth() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __NORTH_ISSET_ID);
  }

  /** Returns true if field north is set (has been assigned a value) and false otherwise */
  public boolean isSetNorth() {
    return EncodingUtils.testBit(__isset_bitfield, __NORTH_ISSET_ID);
  }

  public void setNorthIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __NORTH_ISSET_ID, value);
  }

  public int getEast() {
    return this.east;
  }

  public RoundResult setEast(int east) {
    this.east = east;
    setEastIsSet(true);
    return this;
  }

  public void unsetEast() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __EAST_ISSET_ID);
  }

  /** Returns true if field east is set (has been assigned a value) and false otherwise */
  public boolean isSetEast() {
    return EncodingUtils.testBit(__isset_bitfield, __EAST_ISSET_ID);
  }

  public void setEastIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __EAST_ISSET_ID, value);
  }

  public int getSouth() {
    return this.south;
  }

  public RoundResult setSouth(int south) {
    this.south = south;
    setSouthIsSet(true);
    return this;
  }

  public void unsetSouth() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SOUTH_ISSET_ID);
  }

  /** Returns true if field south is set (has been assigned a value) and false otherwise */
  public boolean isSetSouth() {
    return EncodingUtils.testBit(__isset_bitfield, __SOUTH_ISSET_ID);
  }

  public void setSouthIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SOUTH_ISSET_ID, value);
  }

  public int getWest() {
    return this.west;
  }

  public RoundResult setWest(int west) {
    this.west = west;
    setWestIsSet(true);
    return this;
  }

  public void unsetWest() {
    __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __WEST_ISSET_ID);
  }

  /** Returns true if field west is set (has been assigned a value) and false otherwise */
  public boolean isSetWest() {
    return EncodingUtils.testBit(__isset_bitfield, __WEST_ISSET_ID);
  }

  public void setWestIsSet(boolean value) {
    __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __WEST_ISSET_ID, value);
  }

  /**
   * 
   * @see GameStatus
   */
  public GameStatus getStatus() {
    return this.status;
  }

  /**
   * 
   * @see GameStatus
   */
  public RoundResult setStatus(GameStatus status) {
    this.status = status;
    return this;
  }

  public void unsetStatus() {
    this.status = null;
  }

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

  public void setStatusIsSet(boolean value) {
    if (!value) {
      this.status = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case NORTH:
      if (value == null) {
        unsetNorth();
      } else {
        setNorth((Integer)value);
      }
      break;

    case EAST:
      if (value == null) {
        unsetEast();
      } else {
        setEast((Integer)value);
      }
      break;

    case SOUTH:
      if (value == null) {
        unsetSouth();
      } else {
        setSouth((Integer)value);
      }
      break;

    case WEST:
      if (value == null) {
        unsetWest();
      } else {
        setWest((Integer)value);
      }
      break;

    case STATUS:
      if (value == null) {
        unsetStatus();
      } else {
        setStatus((GameStatus)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case NORTH:
      return Integer.valueOf(getNorth());

    case EAST:
      return Integer.valueOf(getEast());

    case SOUTH:
      return Integer.valueOf(getSouth());

    case WEST:
      return Integer.valueOf(getWest());

    case STATUS:
      return getStatus();

    }
    throw new IllegalStateException();
  }

  /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
  public boolean isSet(_Fields field) {
    if (field == null) {
      throw new IllegalArgumentException();
    }

    switch (field) {
    case NORTH:
      return isSetNorth();
    case EAST:
      return isSetEast();
    case SOUTH:
      return isSetSouth();
    case WEST:
      return isSetWest();
    case STATUS:
      return isSetStatus();
    }
    throw new IllegalStateException();
  }

  @Override
  public boolean equals(Object that) {
    if (that == null)
      return false;
    if (that instanceof RoundResult)
      return this.equals((RoundResult)that);
    return false;
  }

  public boolean equals(RoundResult that) {
    if (that == null)
      return false;

    boolean this_present_north = true;
    boolean that_present_north = true;
    if (this_present_north || that_present_north) {
      if (!(this_present_north && that_present_north))
        return false;
      if (this.north != that.north)
        return false;
    }

    boolean this_present_east = true;
    boolean that_present_east = true;
    if (this_present_east || that_present_east) {
      if (!(this_present_east && that_present_east))
        return false;
      if (this.east != that.east)
        return false;
    }

    boolean this_present_south = true;
    boolean that_present_south = true;
    if (this_present_south || that_present_south) {
      if (!(this_present_south && that_present_south))
        return false;
      if (this.south != that.south)
        return false;
    }

    boolean this_present_west = true;
    boolean that_present_west = true;
    if (this_present_west || that_present_west) {
      if (!(this_present_west && that_present_west))
        return false;
      if (this.west != that.west)
        return false;
    }

    boolean this_present_status = true && this.isSetStatus();
    boolean that_present_status = true && that.isSetStatus();
    if (this_present_status || that_present_status) {
      if (!(this_present_status && that_present_status))
        return false;
      if (!this.status.equals(that.status))
        return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    return 0;
  }

  @Override
  public int compareTo(RoundResult other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;

    lastComparison = Boolean.valueOf(isSetNorth()).compareTo(other.isSetNorth());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetNorth()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.north, other.north);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetEast()).compareTo(other.isSetEast());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetEast()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.east, other.east);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetSouth()).compareTo(other.isSetSouth());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetSouth()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.south, other.south);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetWest()).compareTo(other.isSetWest());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetWest()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.west, other.west);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetStatus()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }

  public _Fields fieldForId(int fieldId) {
    return _Fields.findByThriftId(fieldId);
  }

  public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
  }

  public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder("RoundResult(");
    boolean first = true;

    sb.append("north:");
    sb.append(this.north);
    first = false;
    if (!first) sb.append(", ");
    sb.append("east:");
    sb.append(this.east);
    first = false;
    if (!first) sb.append(", ");
    sb.append("south:");
    sb.append(this.south);
    first = false;
    if (!first) sb.append(", ");
    sb.append("west:");
    sb.append(this.west);
    first = false;
    if (!first) sb.append(", ");
    sb.append("status:");
    if (this.status == null) {
      sb.append("null");
    } else {
      sb.append(this.status);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
    // alas, we cannot check 'north' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'east' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'south' because it's a primitive and you chose the non-beans generator.
    // alas, we cannot check 'west' because it's a primitive and you chose the non-beans generator.
    if (status == null) {
      throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
    }
    // check for sub-struct validity
  }

  private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
    try {
      write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
    try {
      // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
      __isset_bitfield = 0;
      read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
    } catch (org.apache.thrift.TException te) {
      throw new java.io.IOException(te);
    }
  }

  private static class RoundResultStandardSchemeFactory implements SchemeFactory {
    public RoundResultStandardScheme getScheme() {
      return new RoundResultStandardScheme();
    }
  }

  private static class RoundResultStandardScheme extends StandardScheme<RoundResult> {

    public void read(org.apache.thrift.protocol.TProtocol iprot, RoundResult struct) throws org.apache.thrift.TException {
      org.apache.thrift.protocol.TField schemeField;
      iprot.readStructBegin();
      while (true)
      {
        schemeField = iprot.readFieldBegin();
        if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
          break;
        }
        switch (schemeField.id) {
          case 1: // NORTH
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.north = iprot.readI32();
              struct.setNorthIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 2: // EAST
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.east = iprot.readI32();
              struct.setEastIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 3: // SOUTH
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.south = iprot.readI32();
              struct.setSouthIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 4: // WEST
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.west = iprot.readI32();
              struct.setWestIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          case 5: // STATUS
            if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
              struct.status = GameStatus.findByValue(iprot.readI32());
              struct.setStatusIsSet(true);
            } else { 
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
            }
            break;
          default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
        }
        iprot.readFieldEnd();
      }
      iprot.readStructEnd();

      // check for required fields of primitive type, which can't be checked in the validate method
      if (!struct.isSetNorth()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'north' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetEast()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'east' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetSouth()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'south' was not found in serialized data! Struct: " + toString());
      }
      if (!struct.isSetWest()) {
        throw new org.apache.thrift.protocol.TProtocolException("Required field 'west' was not found in serialized data! Struct: " + toString());
      }
      struct.validate();
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot, RoundResult struct) throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      oprot.writeFieldBegin(NORTH_FIELD_DESC);
      oprot.writeI32(struct.north);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(EAST_FIELD_DESC);
      oprot.writeI32(struct.east);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(SOUTH_FIELD_DESC);
      oprot.writeI32(struct.south);
      oprot.writeFieldEnd();
      oprot.writeFieldBegin(WEST_FIELD_DESC);
      oprot.writeI32(struct.west);
      oprot.writeFieldEnd();
      if (struct.status != null) {
        oprot.writeFieldBegin(STATUS_FIELD_DESC);
        oprot.writeI32(struct.status.getValue());
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }

  }

  private static class RoundResultTupleSchemeFactory implements SchemeFactory {
    public RoundResultTupleScheme getScheme() {
      return new RoundResultTupleScheme();
    }
  }

  private static class RoundResultTupleScheme extends TupleScheme<RoundResult> {

    @Override
    public void write(org.apache.thrift.protocol.TProtocol prot, RoundResult struct) throws org.apache.thrift.TException {
      TTupleProtocol oprot = (TTupleProtocol) prot;
      oprot.writeI32(struct.north);
      oprot.writeI32(struct.east);
      oprot.writeI32(struct.south);
      oprot.writeI32(struct.west);
      oprot.writeI32(struct.status.getValue());
    }

    @Override
    public void read(org.apache.thrift.protocol.TProtocol prot, RoundResult struct) throws org.apache.thrift.TException {
      TTupleProtocol iprot = (TTupleProtocol) prot;
      struct.north = iprot.readI32();
      struct.setNorthIsSet(true);
      struct.east = iprot.readI32();
      struct.setEastIsSet(true);
      struct.south = iprot.readI32();
      struct.setSouthIsSet(true);
      struct.west = iprot.readI32();
      struct.setWestIsSet(true);
      struct.status = GameStatus.findByValue(iprot.readI32());
      struct.setStatusIsSet(true);
    }
  }

}

