package cn.palmte.work.config.activiti;


import cn.palmte.work.exception.ResponseException;
import lombok.Getter;

/**
 * 流程里的节点类型枚举
 */
@Getter
public enum ActTaskIndexEnum {
    END(-1, "结束节点"),
    COMMON(0, "除发起审批外的用户节点"),
    START(1, "开始节点"),
    FIRST_USER_TASK(2, "发起审批节点");


    private int index;
    private String name;

    ActTaskIndexEnum(int index, String name) {
        this.index = index;
        this.name = name;
    }

    public static ActTaskIndexEnum ofIndex(int index) {
        if (index == END.getIndex()) {
            return END;
        } else if (index == COMMON.getIndex()) {
            return COMMON;
        } else if (index == START.getIndex()) {
            return START;
        } else if (index == FIRST_USER_TASK.getIndex()) {
            return FIRST_USER_TASK;
        } else {
            throw new ResponseException("不支持的节点类型【" + index + "】");
        }
    }
}
