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

    FIXED(1, "固定值"),

    FORM_VARIABLE(2, "表单变量"),

    MODEL_VARIABLE(3, "流程变量"),

    CUSTOM(4, "组合");

    private final Integer code;

    private final String name;

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

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

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