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

    BEFORE_ADD_SIGN(10, "前加签"),

    AFTER_ADD_SIGN(20, "后加签");

    private final Integer code;

    private final String name;

    AddSignTypeEnum(Integer value, String name) {
        this.code = value;
        this.name = name;
    }

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

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