package com.friday.operation.api.distributor.constant;

public enum TaieJobState {
    Pending("Pending","等待启动"),
    Running("Running","运行中"),
    Success("Success","成功"),
    Fail("Fail","失败"),
    Faulted("Faulted","异常终止"),
    Terminating("Terminating","终止中"),
    Terminated("Terminated","已终止"),
    Pausing("Pausing","暂停中"),
    Paused("Paused","已暂停"),
    Resuming("Resuming","恢复中"),
    Invalid("Invalid","无效")

    ;

    private String state;
    private String desc;

    TaieJobState(String state, String desc){
        this.state = state;
        this.desc = desc;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getDecs() {
        return desc;
    }

    public void setDecs(String desc) {
        this.desc = desc;
    }

    static public boolean isFinished(String status) {
        return status.equals(Faulted.name()) ||
                status.equals(Success.name()) ||
                status.equals(Fail.name()) ||
                status.equals(Terminated.name());
    }

    static public boolean isRunning(String status) {
        return status.equals(Pending.name()) ||
                status.equals(Running.name()) ||
                status.equals(Terminating.name()) ||
                status.equals(Pausing.name()) ||
                status.equals(Paused.name()) ||
                status.equals(Resuming.name());
    }

    static public boolean isSuccess(String status) {
        return status.equals(Success.name());
    }

    static public boolean isFailed(String status) {
        return status.equals(Faulted.name()) ||
                status.equals(Fail.name());
    }

    static public boolean isStopped(String status) {
        return status.equals(Terminated.name());
    }
}
