package io.synor.compute;

/**
 * Job execution status.
 */
public enum JobStatus {
    /** Job is pending submission */
    PENDING("pending"),
    /** Job is queued for execution */
    QUEUED("queued"),
    /** Job is currently running */
    RUNNING("running"),
    /** Job completed successfully */
    COMPLETED("completed"),
    /** Job failed */
    FAILED("failed"),
    /** Job was cancelled */
    CANCELLED("cancelled");

    private final String value;

    JobStatus(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    public static JobStatus fromValue(String value) {
        for (JobStatus status : values()) {
            if (status.value.equalsIgnoreCase(value)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown job status: " + value);
    }
}
