package jalview.ws2.api; public enum JobStatus { /** Job has invalid inputs and cannot be started. */ INVALID, /** Job is created and ready for submission. */ READY, /** Job has been submitted and awaits processing. */ SUBMITTED, /** Job has been queued for execution */ QUEUED, /** Job is running */ RUNNING, /** Job has completed successfully. */ COMPLETED, /** Job has finished with errors. */ FAILED, /** Job has been cancelled by the user. */ CANCELLED, /** Job cannot be processed due to server error. */ SERVER_ERROR, /** Job status cannot be determined. */ UNKNOWN; /** * Returns true if the status corresponds to the job completed due to normal * termination, error or cancellation. * * @return {@value true} if status corresponds to a finished job. */ public boolean isDone() { switch (this) { case COMPLETED: case FAILED: case CANCELLED: case SERVER_ERROR: return true; case INVALID: case READY: case SUBMITTED: case QUEUED: case RUNNING: case UNKNOWN: return false; default: throw new AssertionError("non-exhaustive switch statement"); } } public boolean isCompleted() { return this == COMPLETED; } public boolean isCancelled() { return this == CANCELLED; } }