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

    READ("Y", "已读"),

    UN_READ("N", "未读");

    private final String code;

    private final String name;

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

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

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

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