package cn.stylefeng.workflow.api.enums;

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

@Getter
public enum FlowLogLevelEnum implements ReadableEnum<FlowLogLevelEnum> {

    INFO("info", "信息"),

    WARN("warn", "警告"),

    ERROR("error", "错误"),

    FATAL("fatal", "致命");

    private final String code;

    private final String name;

    FlowLogLevelEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

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

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

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