WangHan
2024-09-12 d5855a4926926698b740bc6c7ba489de47adb68b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package tech.powerjob.common.enums;
 
import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Getter;
 
import java.util.Collections;
import java.util.List;
 
/**
 * Workflow 任务运行状态
 *
 * @author tjq
 * @since 2020/5/26
 */
@Getter
@AllArgsConstructor
public enum WorkflowInstanceStatus {
    /**
     * 初始状态为等待调度
     */
    WAITING(1, "等待调度"),
    RUNNING(2, "运行中"),
    FAILED(3, "失败"),
    SUCCEED(4, "成功"),
    STOPPED(10, "手动停止");
 
    /**
     * 广义的运行状态
     */
    public static final List<Integer> GENERALIZED_RUNNING_STATUS = Collections.unmodifiableList(Lists.newArrayList(WAITING.v, RUNNING.v));
    /**
     * 结束状态
     */
    public static final List<Integer> FINISHED_STATUS = Collections.unmodifiableList(Lists.newArrayList(FAILED.v, SUCCEED.v, STOPPED.v));
 
    private final int v;
 
    private final String des;
 
    public static WorkflowInstanceStatus of(int v) {
        for (WorkflowInstanceStatus is : values()) {
            if (v == is.v) {
                return is;
            }
        }
        throw new IllegalArgumentException("WorkflowInstanceStatus has no item for value " + v);
    }
}