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

    AGREE(1, "同意"),

    NOT_AGREE(2, "不同意");

    private final Integer status;

    private final String name;

    SuggestFlagEnum(int status, String name) {
        this.status = status;
        this.name = name;
    }

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

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