package cn.stylefeng.workflow.api.enums.subflow;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.rule.base.ReadableEnum;
import lombok.Getter;

@Getter
public enum DeptCounterSignTypeEnum implements ReadableEnum<DeptCounterSignTypeEnum> {

    FORM_ELEMENT(1, "来自表单元素"),

    FLOW_VARIABLE(2, "来自流程变量");

    private final Integer code;

    private final String name;

    DeptCounterSignTypeEnum(Integer nodeType, String name) {
        this.code = nodeType;
        this.name = name;
    }

    @Override
    public Object getKey() {
        return code;
    }

    @Override
    public DeptCounterSignTypeEnum parseToEnum(String originValue) {
        if (ObjectUtil.isEmpty(originValue)) {
            return null;
        }
        for (DeptCounterSignTypeEnum value : DeptCounterSignTypeEnum.values()) {
            if (value.code.equals(Convert.toInt(originValue))) {
                return value;
            }
        }
        return null;
    }
}
