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

    NONE(10, "无活动"),

    RPC(20, "RPC远程调用"),

    HTTP(30, "HTTP接口调用");

    private final Integer status;

    private final String name;

    ActivityTypeEnum(Integer value, String name) {
        this.status = value;
        this.name = name;
    }

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

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