/**
 * Autogenerated by Thrift Compiler (0.7.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 */
package org.apache.hadoop.thriftfs.jobtracker.api;

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;

/**
 * Status of *all* jobs, not just currently running ones
 */
public class ThriftJobInProgress implements org.apache.thrift.TBase<ThriftJobInProgress, ThriftJobInProgress._Fields>, java.io.Serializable, Cloneable {
  private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ThriftJobInProgress");

  private static final org.apache.thrift.protocol.TField PROFILE_FIELD_DESC = new org.apache.thrift.protocol.TField("profile", org.apache.thrift.protocol.TType.STRUCT, (short)1);
  private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)2);
  private static final org.apache.thrift.protocol.TField JOB_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("jobID", org.apache.thrift.protocol.TType.STRUCT, (short)3);
  private static final org.apache.thrift.protocol.TField DESIRED_MAPS_FIELD_DESC = new org.apache.thrift.protocol.TField("desiredMaps", org.apache.thrift.protocol.TType.I32, (short)4);
  private static final org.apache.thrift.protocol.TField DESIRED_REDUCES_FIELD_DESC = new org.apache.thrift.protocol.TField("desiredReduces", org.apache.thrift.protocol.TType.I32, (short)5);
  private static final org.apache.thrift.protocol.TField FINISHED_MAPS_FIELD_DESC = new org.apache.thrift.protocol.TField("finishedMaps", org.apache.thrift.protocol.TType.I32, (short)6);
  private static final org.apache.thrift.protocol.TField FINISHED_REDUCES_FIELD_DESC = new org.apache.thrift.protocol.TField("finishedReduces", org.apache.thrift.protocol.TType.I32, (short)7);
  private static final org.apache.thrift.protocol.TField PRIORITY_FIELD_DESC = new org.apache.thrift.protocol.TField("priority", org.apache.thrift.protocol.TType.I32, (short)8);
  private static final org.apache.thrift.protocol.TField START_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("startTime", org.apache.thrift.protocol.TType.I64, (short)11);
  private static final org.apache.thrift.protocol.TField FINISH_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("finishTime", org.apache.thrift.protocol.TType.I64, (short)12);
  private static final org.apache.thrift.protocol.TField LAUNCH_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("launchTime", org.apache.thrift.protocol.TType.I64, (short)13);
  private static final org.apache.thrift.protocol.TField TASKS_FIELD_DESC = new org.apache.thrift.protocol.TField("tasks", org.apache.thrift.protocol.TType.STRUCT, (short)23);

  public ThriftJobProfile profile; // required
  public ThriftJobStatus status; // required
  public ThriftJobID jobID; // required
  public int desiredMaps; // required
  public int desiredReduces; // required
  public int finishedMaps; // required
  public int finishedReduces; // required
  /**
   * 
   * @see ThriftJobPriority
   */
  public ThriftJobPriority priority; // required
  public long startTime; // required
  public long finishTime; // required
  public long launchTime; // required
  public ThriftTaskInProgressList tasks; // 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 {
    PROFILE((short)1, "profile"),
    STATUS((short)2, "status"),
    JOB_ID((short)3, "jobID"),
    DESIRED_MAPS((short)4, "desiredMaps"),
    DESIRED_REDUCES((short)5, "desiredReduces"),
    FINISHED_MAPS((short)6, "finishedMaps"),
    FINISHED_REDUCES((short)7, "finishedReduces"),
    /**
     * 
     * @see ThriftJobPriority
     */
    PRIORITY((short)8, "priority"),
    START_TIME((short)11, "startTime"),
    FINISH_TIME((short)12, "finishTime"),
    LAUNCH_TIME((short)13, "launchTime"),
    TASKS((short)23, "tasks");

    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: // PROFILE
          return PROFILE;
        case 2: // STATUS
          return STATUS;
        case 3: // JOB_ID
          return JOB_ID;
        case 4: // DESIRED_MAPS
          return DESIRED_MAPS;
        case 5: // DESIRED_REDUCES
          return DESIRED_REDUCES;
        case 6: // FINISHED_MAPS
          return FINISHED_MAPS;
        case 7: // FINISHED_REDUCES
          return FINISHED_REDUCES;
        case 8: // PRIORITY
          return PRIORITY;
        case 11: // START_TIME
          return START_TIME;
        case 12: // FINISH_TIME
          return FINISH_TIME;
        case 13: // LAUNCH_TIME
          return LAUNCH_TIME;
        case 23: // TASKS
          return TASKS;
        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 __DESIREDMAPS_ISSET_ID = 0;
  private static final int __DESIREDREDUCES_ISSET_ID = 1;
  private static final int __FINISHEDMAPS_ISSET_ID = 2;
  private static final int __FINISHEDREDUCES_ISSET_ID = 3;
  private static final int __STARTTIME_ISSET_ID = 4;
  private static final int __FINISHTIME_ISSET_ID = 5;
  private static final int __LAUNCHTIME_ISSET_ID = 6;
  private BitSet __isset_bit_vector = new BitSet(7);

  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.PROFILE, new org.apache.thrift.meta_data.FieldMetaData("profile", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ThriftJobProfile.class)));
    tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ThriftJobStatus.class)));
    tmpMap.put(_Fields.JOB_ID, new org.apache.thrift.meta_data.FieldMetaData("jobID", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ThriftJobID.class)));
    tmpMap.put(_Fields.DESIRED_MAPS, new org.apache.thrift.meta_data.FieldMetaData("desiredMaps", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.DESIRED_REDUCES, new org.apache.thrift.meta_data.FieldMetaData("desiredReduces", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.FINISHED_MAPS, new org.apache.thrift.meta_data.FieldMetaData("finishedMaps", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.FINISHED_REDUCES, new org.apache.thrift.meta_data.FieldMetaData("finishedReduces", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
    tmpMap.put(_Fields.PRIORITY, new org.apache.thrift.meta_data.FieldMetaData("priority", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, ThriftJobPriority.class)));
    tmpMap.put(_Fields.START_TIME, new org.apache.thrift.meta_data.FieldMetaData("startTime", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.FINISH_TIME, new org.apache.thrift.meta_data.FieldMetaData("finishTime", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.LAUNCH_TIME, new org.apache.thrift.meta_data.FieldMetaData("launchTime", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
    tmpMap.put(_Fields.TASKS, new org.apache.thrift.meta_data.FieldMetaData("tasks", org.apache.thrift.TFieldRequirementType.DEFAULT, 
        new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, ThriftTaskInProgressList.class)));
    metaDataMap = Collections.unmodifiableMap(tmpMap);
    org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ThriftJobInProgress.class, metaDataMap);
  }

  public ThriftJobInProgress() {
  }

  public ThriftJobInProgress(
    ThriftJobProfile profile,
    ThriftJobStatus status,
    ThriftJobID jobID,
    int desiredMaps,
    int desiredReduces,
    int finishedMaps,
    int finishedReduces,
    ThriftJobPriority priority,
    long startTime,
    long finishTime,
    long launchTime,
    ThriftTaskInProgressList tasks)
  {
    this();
    this.profile = profile;
    this.status = status;
    this.jobID = jobID;
    this.desiredMaps = desiredMaps;
    setDesiredMapsIsSet(true);
    this.desiredReduces = desiredReduces;
    setDesiredReducesIsSet(true);
    this.finishedMaps = finishedMaps;
    setFinishedMapsIsSet(true);
    this.finishedReduces = finishedReduces;
    setFinishedReducesIsSet(true);
    this.priority = priority;
    this.startTime = startTime;
    setStartTimeIsSet(true);
    this.finishTime = finishTime;
    setFinishTimeIsSet(true);
    this.launchTime = launchTime;
    setLaunchTimeIsSet(true);
    this.tasks = tasks;
  }

  /**
   * Performs a deep copy on <i>other</i>.
   */
  public ThriftJobInProgress(ThriftJobInProgress other) {
    __isset_bit_vector.clear();
    __isset_bit_vector.or(other.__isset_bit_vector);
    if (other.isSetProfile()) {
      this.profile = new ThriftJobProfile(other.profile);
    }
    if (other.isSetStatus()) {
      this.status = new ThriftJobStatus(other.status);
    }
    if (other.isSetJobID()) {
      this.jobID = new ThriftJobID(other.jobID);
    }
    this.desiredMaps = other.desiredMaps;
    this.desiredReduces = other.desiredReduces;
    this.finishedMaps = other.finishedMaps;
    this.finishedReduces = other.finishedReduces;
    if (other.isSetPriority()) {
      this.priority = other.priority;
    }
    this.startTime = other.startTime;
    this.finishTime = other.finishTime;
    this.launchTime = other.launchTime;
    if (other.isSetTasks()) {
      this.tasks = new ThriftTaskInProgressList(other.tasks);
    }
  }

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

  @Override
  public void clear() {
    this.profile = null;
    this.status = null;
    this.jobID = null;
    setDesiredMapsIsSet(false);
    this.desiredMaps = 0;
    setDesiredReducesIsSet(false);
    this.desiredReduces = 0;
    setFinishedMapsIsSet(false);
    this.finishedMaps = 0;
    setFinishedReducesIsSet(false);
    this.finishedReduces = 0;
    this.priority = null;
    setStartTimeIsSet(false);
    this.startTime = 0;
    setFinishTimeIsSet(false);
    this.finishTime = 0;
    setLaunchTimeIsSet(false);
    this.launchTime = 0;
    this.tasks = null;
  }

  public ThriftJobProfile getProfile() {
    return this.profile;
  }

  public ThriftJobInProgress setProfile(ThriftJobProfile profile) {
    this.profile = profile;
    return this;
  }

  public void unsetProfile() {
    this.profile = null;
  }

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

  public void setProfileIsSet(boolean value) {
    if (!value) {
      this.profile = null;
    }
  }

  public ThriftJobStatus getStatus() {
    return this.status;
  }

  public ThriftJobInProgress setStatus(ThriftJobStatus 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 ThriftJobID getJobID() {
    return this.jobID;
  }

  public ThriftJobInProgress setJobID(ThriftJobID jobID) {
    this.jobID = jobID;
    return this;
  }

  public void unsetJobID() {
    this.jobID = null;
  }

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

  public void setJobIDIsSet(boolean value) {
    if (!value) {
      this.jobID = null;
    }
  }

  public int getDesiredMaps() {
    return this.desiredMaps;
  }

  public ThriftJobInProgress setDesiredMaps(int desiredMaps) {
    this.desiredMaps = desiredMaps;
    setDesiredMapsIsSet(true);
    return this;
  }

  public void unsetDesiredMaps() {
    __isset_bit_vector.clear(__DESIREDMAPS_ISSET_ID);
  }

  /** Returns true if field desiredMaps is set (has been assigned a value) and false otherwise */
  public boolean isSetDesiredMaps() {
    return __isset_bit_vector.get(__DESIREDMAPS_ISSET_ID);
  }

  public void setDesiredMapsIsSet(boolean value) {
    __isset_bit_vector.set(__DESIREDMAPS_ISSET_ID, value);
  }

  public int getDesiredReduces() {
    return this.desiredReduces;
  }

  public ThriftJobInProgress setDesiredReduces(int desiredReduces) {
    this.desiredReduces = desiredReduces;
    setDesiredReducesIsSet(true);
    return this;
  }

  public void unsetDesiredReduces() {
    __isset_bit_vector.clear(__DESIREDREDUCES_ISSET_ID);
  }

  /** Returns true if field desiredReduces is set (has been assigned a value) and false otherwise */
  public boolean isSetDesiredReduces() {
    return __isset_bit_vector.get(__DESIREDREDUCES_ISSET_ID);
  }

  public void setDesiredReducesIsSet(boolean value) {
    __isset_bit_vector.set(__DESIREDREDUCES_ISSET_ID, value);
  }

  public int getFinishedMaps() {
    return this.finishedMaps;
  }

  public ThriftJobInProgress setFinishedMaps(int finishedMaps) {
    this.finishedMaps = finishedMaps;
    setFinishedMapsIsSet(true);
    return this;
  }

  public void unsetFinishedMaps() {
    __isset_bit_vector.clear(__FINISHEDMAPS_ISSET_ID);
  }

  /** Returns true if field finishedMaps is set (has been assigned a value) and false otherwise */
  public boolean isSetFinishedMaps() {
    return __isset_bit_vector.get(__FINISHEDMAPS_ISSET_ID);
  }

  public void setFinishedMapsIsSet(boolean value) {
    __isset_bit_vector.set(__FINISHEDMAPS_ISSET_ID, value);
  }

  public int getFinishedReduces() {
    return this.finishedReduces;
  }

  public ThriftJobInProgress setFinishedReduces(int finishedReduces) {
    this.finishedReduces = finishedReduces;
    setFinishedReducesIsSet(true);
    return this;
  }

  public void unsetFinishedReduces() {
    __isset_bit_vector.clear(__FINISHEDREDUCES_ISSET_ID);
  }

  /** Returns true if field finishedReduces is set (has been assigned a value) and false otherwise */
  public boolean isSetFinishedReduces() {
    return __isset_bit_vector.get(__FINISHEDREDUCES_ISSET_ID);
  }

  public void setFinishedReducesIsSet(boolean value) {
    __isset_bit_vector.set(__FINISHEDREDUCES_ISSET_ID, value);
  }

  /**
   * 
   * @see ThriftJobPriority
   */
  public ThriftJobPriority getPriority() {
    return this.priority;
  }

  /**
   * 
   * @see ThriftJobPriority
   */
  public ThriftJobInProgress setPriority(ThriftJobPriority priority) {
    this.priority = priority;
    return this;
  }

  public void unsetPriority() {
    this.priority = null;
  }

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

  public void setPriorityIsSet(boolean value) {
    if (!value) {
      this.priority = null;
    }
  }

  public long getStartTime() {
    return this.startTime;
  }

  public ThriftJobInProgress setStartTime(long startTime) {
    this.startTime = startTime;
    setStartTimeIsSet(true);
    return this;
  }

  public void unsetStartTime() {
    __isset_bit_vector.clear(__STARTTIME_ISSET_ID);
  }

  /** Returns true if field startTime is set (has been assigned a value) and false otherwise */
  public boolean isSetStartTime() {
    return __isset_bit_vector.get(__STARTTIME_ISSET_ID);
  }

  public void setStartTimeIsSet(boolean value) {
    __isset_bit_vector.set(__STARTTIME_ISSET_ID, value);
  }

  public long getFinishTime() {
    return this.finishTime;
  }

  public ThriftJobInProgress setFinishTime(long finishTime) {
    this.finishTime = finishTime;
    setFinishTimeIsSet(true);
    return this;
  }

  public void unsetFinishTime() {
    __isset_bit_vector.clear(__FINISHTIME_ISSET_ID);
  }

  /** Returns true if field finishTime is set (has been assigned a value) and false otherwise */
  public boolean isSetFinishTime() {
    return __isset_bit_vector.get(__FINISHTIME_ISSET_ID);
  }

  public void setFinishTimeIsSet(boolean value) {
    __isset_bit_vector.set(__FINISHTIME_ISSET_ID, value);
  }

  public long getLaunchTime() {
    return this.launchTime;
  }

  public ThriftJobInProgress setLaunchTime(long launchTime) {
    this.launchTime = launchTime;
    setLaunchTimeIsSet(true);
    return this;
  }

  public void unsetLaunchTime() {
    __isset_bit_vector.clear(__LAUNCHTIME_ISSET_ID);
  }

  /** Returns true if field launchTime is set (has been assigned a value) and false otherwise */
  public boolean isSetLaunchTime() {
    return __isset_bit_vector.get(__LAUNCHTIME_ISSET_ID);
  }

  public void setLaunchTimeIsSet(boolean value) {
    __isset_bit_vector.set(__LAUNCHTIME_ISSET_ID, value);
  }

  public ThriftTaskInProgressList getTasks() {
    return this.tasks;
  }

  public ThriftJobInProgress setTasks(ThriftTaskInProgressList tasks) {
    this.tasks = tasks;
    return this;
  }

  public void unsetTasks() {
    this.tasks = null;
  }

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

  public void setTasksIsSet(boolean value) {
    if (!value) {
      this.tasks = null;
    }
  }

  public void setFieldValue(_Fields field, Object value) {
    switch (field) {
    case PROFILE:
      if (value == null) {
        unsetProfile();
      } else {
        setProfile((ThriftJobProfile)value);
      }
      break;

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

    case JOB_ID:
      if (value == null) {
        unsetJobID();
      } else {
        setJobID((ThriftJobID)value);
      }
      break;

    case DESIRED_MAPS:
      if (value == null) {
        unsetDesiredMaps();
      } else {
        setDesiredMaps((Integer)value);
      }
      break;

    case DESIRED_REDUCES:
      if (value == null) {
        unsetDesiredReduces();
      } else {
        setDesiredReduces((Integer)value);
      }
      break;

    case FINISHED_MAPS:
      if (value == null) {
        unsetFinishedMaps();
      } else {
        setFinishedMaps((Integer)value);
      }
      break;

    case FINISHED_REDUCES:
      if (value == null) {
        unsetFinishedReduces();
      } else {
        setFinishedReduces((Integer)value);
      }
      break;

    case PRIORITY:
      if (value == null) {
        unsetPriority();
      } else {
        setPriority((ThriftJobPriority)value);
      }
      break;

    case START_TIME:
      if (value == null) {
        unsetStartTime();
      } else {
        setStartTime((Long)value);
      }
      break;

    case FINISH_TIME:
      if (value == null) {
        unsetFinishTime();
      } else {
        setFinishTime((Long)value);
      }
      break;

    case LAUNCH_TIME:
      if (value == null) {
        unsetLaunchTime();
      } else {
        setLaunchTime((Long)value);
      }
      break;

    case TASKS:
      if (value == null) {
        unsetTasks();
      } else {
        setTasks((ThriftTaskInProgressList)value);
      }
      break;

    }
  }

  public Object getFieldValue(_Fields field) {
    switch (field) {
    case PROFILE:
      return getProfile();

    case STATUS:
      return getStatus();

    case JOB_ID:
      return getJobID();

    case DESIRED_MAPS:
      return Integer.valueOf(getDesiredMaps());

    case DESIRED_REDUCES:
      return Integer.valueOf(getDesiredReduces());

    case FINISHED_MAPS:
      return Integer.valueOf(getFinishedMaps());

    case FINISHED_REDUCES:
      return Integer.valueOf(getFinishedReduces());

    case PRIORITY:
      return getPriority();

    case START_TIME:
      return Long.valueOf(getStartTime());

    case FINISH_TIME:
      return Long.valueOf(getFinishTime());

    case LAUNCH_TIME:
      return Long.valueOf(getLaunchTime());

    case TASKS:
      return getTasks();

    }
    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 PROFILE:
      return isSetProfile();
    case STATUS:
      return isSetStatus();
    case JOB_ID:
      return isSetJobID();
    case DESIRED_MAPS:
      return isSetDesiredMaps();
    case DESIRED_REDUCES:
      return isSetDesiredReduces();
    case FINISHED_MAPS:
      return isSetFinishedMaps();
    case FINISHED_REDUCES:
      return isSetFinishedReduces();
    case PRIORITY:
      return isSetPriority();
    case START_TIME:
      return isSetStartTime();
    case FINISH_TIME:
      return isSetFinishTime();
    case LAUNCH_TIME:
      return isSetLaunchTime();
    case TASKS:
      return isSetTasks();
    }
    throw new IllegalStateException();
  }

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

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

    boolean this_present_profile = true && this.isSetProfile();
    boolean that_present_profile = true && that.isSetProfile();
    if (this_present_profile || that_present_profile) {
      if (!(this_present_profile && that_present_profile))
        return false;
      if (!this.profile.equals(that.profile))
        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;
    }

    boolean this_present_jobID = true && this.isSetJobID();
    boolean that_present_jobID = true && that.isSetJobID();
    if (this_present_jobID || that_present_jobID) {
      if (!(this_present_jobID && that_present_jobID))
        return false;
      if (!this.jobID.equals(that.jobID))
        return false;
    }

    boolean this_present_desiredMaps = true;
    boolean that_present_desiredMaps = true;
    if (this_present_desiredMaps || that_present_desiredMaps) {
      if (!(this_present_desiredMaps && that_present_desiredMaps))
        return false;
      if (this.desiredMaps != that.desiredMaps)
        return false;
    }

    boolean this_present_desiredReduces = true;
    boolean that_present_desiredReduces = true;
    if (this_present_desiredReduces || that_present_desiredReduces) {
      if (!(this_present_desiredReduces && that_present_desiredReduces))
        return false;
      if (this.desiredReduces != that.desiredReduces)
        return false;
    }

    boolean this_present_finishedMaps = true;
    boolean that_present_finishedMaps = true;
    if (this_present_finishedMaps || that_present_finishedMaps) {
      if (!(this_present_finishedMaps && that_present_finishedMaps))
        return false;
      if (this.finishedMaps != that.finishedMaps)
        return false;
    }

    boolean this_present_finishedReduces = true;
    boolean that_present_finishedReduces = true;
    if (this_present_finishedReduces || that_present_finishedReduces) {
      if (!(this_present_finishedReduces && that_present_finishedReduces))
        return false;
      if (this.finishedReduces != that.finishedReduces)
        return false;
    }

    boolean this_present_priority = true && this.isSetPriority();
    boolean that_present_priority = true && that.isSetPriority();
    if (this_present_priority || that_present_priority) {
      if (!(this_present_priority && that_present_priority))
        return false;
      if (!this.priority.equals(that.priority))
        return false;
    }

    boolean this_present_startTime = true;
    boolean that_present_startTime = true;
    if (this_present_startTime || that_present_startTime) {
      if (!(this_present_startTime && that_present_startTime))
        return false;
      if (this.startTime != that.startTime)
        return false;
    }

    boolean this_present_finishTime = true;
    boolean that_present_finishTime = true;
    if (this_present_finishTime || that_present_finishTime) {
      if (!(this_present_finishTime && that_present_finishTime))
        return false;
      if (this.finishTime != that.finishTime)
        return false;
    }

    boolean this_present_launchTime = true;
    boolean that_present_launchTime = true;
    if (this_present_launchTime || that_present_launchTime) {
      if (!(this_present_launchTime && that_present_launchTime))
        return false;
      if (this.launchTime != that.launchTime)
        return false;
    }

    boolean this_present_tasks = true && this.isSetTasks();
    boolean that_present_tasks = true && that.isSetTasks();
    if (this_present_tasks || that_present_tasks) {
      if (!(this_present_tasks && that_present_tasks))
        return false;
      if (!this.tasks.equals(that.tasks))
        return false;
    }

    return true;
  }

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

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

    int lastComparison = 0;
    ThriftJobInProgress typedOther = (ThriftJobInProgress)other;

    lastComparison = Boolean.valueOf(isSetProfile()).compareTo(typedOther.isSetProfile());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetProfile()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.profile, typedOther.profile);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetStatus()).compareTo(typedOther.isSetStatus());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetStatus()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, typedOther.status);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetJobID()).compareTo(typedOther.isSetJobID());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetJobID()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jobID, typedOther.jobID);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDesiredMaps()).compareTo(typedOther.isSetDesiredMaps());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDesiredMaps()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.desiredMaps, typedOther.desiredMaps);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetDesiredReduces()).compareTo(typedOther.isSetDesiredReduces());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetDesiredReduces()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.desiredReduces, typedOther.desiredReduces);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetFinishedMaps()).compareTo(typedOther.isSetFinishedMaps());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFinishedMaps()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.finishedMaps, typedOther.finishedMaps);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetFinishedReduces()).compareTo(typedOther.isSetFinishedReduces());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFinishedReduces()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.finishedReduces, typedOther.finishedReduces);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetPriority()).compareTo(typedOther.isSetPriority());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetPriority()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.priority, typedOther.priority);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetStartTime()).compareTo(typedOther.isSetStartTime());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetStartTime()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.startTime, typedOther.startTime);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetFinishTime()).compareTo(typedOther.isSetFinishTime());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetFinishTime()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.finishTime, typedOther.finishTime);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetLaunchTime()).compareTo(typedOther.isSetLaunchTime());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetLaunchTime()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.launchTime, typedOther.launchTime);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(isSetTasks()).compareTo(typedOther.isSetTasks());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (isSetTasks()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tasks, typedOther.tasks);
      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 {
    org.apache.thrift.protocol.TField field;
    iprot.readStructBegin();
    while (true)
    {
      field = iprot.readFieldBegin();
      if (field.type == org.apache.thrift.protocol.TType.STOP) { 
        break;
      }
      switch (field.id) {
        case 1: // PROFILE
          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
            this.profile = new ThriftJobProfile();
            this.profile.read(iprot);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 2: // STATUS
          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
            this.status = new ThriftJobStatus();
            this.status.read(iprot);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 3: // JOB_ID
          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
            this.jobID = new ThriftJobID();
            this.jobID.read(iprot);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 4: // DESIRED_MAPS
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.desiredMaps = iprot.readI32();
            setDesiredMapsIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 5: // DESIRED_REDUCES
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.desiredReduces = iprot.readI32();
            setDesiredReducesIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 6: // FINISHED_MAPS
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.finishedMaps = iprot.readI32();
            setFinishedMapsIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 7: // FINISHED_REDUCES
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.finishedReduces = iprot.readI32();
            setFinishedReducesIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 8: // PRIORITY
          if (field.type == org.apache.thrift.protocol.TType.I32) {
            this.priority = ThriftJobPriority.findByValue(iprot.readI32());
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 11: // START_TIME
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.startTime = iprot.readI64();
            setStartTimeIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 12: // FINISH_TIME
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.finishTime = iprot.readI64();
            setFinishTimeIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 13: // LAUNCH_TIME
          if (field.type == org.apache.thrift.protocol.TType.I64) {
            this.launchTime = iprot.readI64();
            setLaunchTimeIsSet(true);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        case 23: // TASKS
          if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
            this.tasks = new ThriftTaskInProgressList();
            this.tasks.read(iprot);
          } else { 
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
          }
          break;
        default:
          org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
      }
      iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    // check for required fields of primitive type, which can't be checked in the validate method
    validate();
  }

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

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.profile != null) {
      oprot.writeFieldBegin(PROFILE_FIELD_DESC);
      this.profile.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.status != null) {
      oprot.writeFieldBegin(STATUS_FIELD_DESC);
      this.status.write(oprot);
      oprot.writeFieldEnd();
    }
    if (this.jobID != null) {
      oprot.writeFieldBegin(JOB_ID_FIELD_DESC);
      this.jobID.write(oprot);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(DESIRED_MAPS_FIELD_DESC);
    oprot.writeI32(this.desiredMaps);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(DESIRED_REDUCES_FIELD_DESC);
    oprot.writeI32(this.desiredReduces);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(FINISHED_MAPS_FIELD_DESC);
    oprot.writeI32(this.finishedMaps);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(FINISHED_REDUCES_FIELD_DESC);
    oprot.writeI32(this.finishedReduces);
    oprot.writeFieldEnd();
    if (this.priority != null) {
      oprot.writeFieldBegin(PRIORITY_FIELD_DESC);
      oprot.writeI32(this.priority.getValue());
      oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(START_TIME_FIELD_DESC);
    oprot.writeI64(this.startTime);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(FINISH_TIME_FIELD_DESC);
    oprot.writeI64(this.finishTime);
    oprot.writeFieldEnd();
    oprot.writeFieldBegin(LAUNCH_TIME_FIELD_DESC);
    oprot.writeI64(this.launchTime);
    oprot.writeFieldEnd();
    if (this.tasks != null) {
      oprot.writeFieldBegin(TASKS_FIELD_DESC);
      this.tasks.write(oprot);
      oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
  }

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

    sb.append("profile:");
    if (this.profile == null) {
      sb.append("null");
    } else {
      sb.append(this.profile);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("status:");
    if (this.status == null) {
      sb.append("null");
    } else {
      sb.append(this.status);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("jobID:");
    if (this.jobID == null) {
      sb.append("null");
    } else {
      sb.append(this.jobID);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("desiredMaps:");
    sb.append(this.desiredMaps);
    first = false;
    if (!first) sb.append(", ");
    sb.append("desiredReduces:");
    sb.append(this.desiredReduces);
    first = false;
    if (!first) sb.append(", ");
    sb.append("finishedMaps:");
    sb.append(this.finishedMaps);
    first = false;
    if (!first) sb.append(", ");
    sb.append("finishedReduces:");
    sb.append(this.finishedReduces);
    first = false;
    if (!first) sb.append(", ");
    sb.append("priority:");
    if (this.priority == null) {
      sb.append("null");
    } else {
      sb.append(this.priority);
    }
    first = false;
    if (!first) sb.append(", ");
    sb.append("startTime:");
    sb.append(this.startTime);
    first = false;
    if (!first) sb.append(", ");
    sb.append("finishTime:");
    sb.append(this.finishTime);
    first = false;
    if (!first) sb.append(", ");
    sb.append("launchTime:");
    sb.append(this.launchTime);
    first = false;
    if (!first) sb.append(", ");
    sb.append("tasks:");
    if (this.tasks == null) {
      sb.append("null");
    } else {
      sb.append(this.tasks);
    }
    first = false;
    sb.append(")");
    return sb.toString();
  }

  public void validate() throws org.apache.thrift.TException {
    // check for required fields
  }

  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_bit_vector = new BitSet(1);
      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);
    }
  }

}

