package cn.stylefeng.workflow.api.enums;

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 ApproverNodeTypeEnum implements ReadableEnum<ApproverNodeTypeEnum> {

    SINGLE(10, "单人活动"),

    OR_APPROVE(20, "多人单一"),

    AND_APPROVE(30, "多人并行"),

    ONE_BY_ONE(40, "多人顺序"),

    INTERNAL_LOOP(50, "内部循环");

    private final Integer mode;

    private final String name;

    ApproverNodeTypeEnum(Integer value, String name) {
        this.mode = value;
        this.name = name;
    }

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

    @Override
    public Object getName() {
        return name;
    }

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

}
