package cn.stylefeng.workflow.api.enums.condition;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

@Getter
public enum ConditionOptEnum {

    EQ("eq", "==", "等于"),

    NE("ne", "!=", "不等于"),

    GT("gt", ">", "大于"),

    GE("ge", ">=", "大于等于"),

    LT("lt", "<", "小于"),

    LE("le", "<=", "小于等于"),

    CONTAIN("contain", "contain", "包含");

    private final String optType;

    private final String optCode;

    private final String optName;

    ConditionOptEnum(String optType, String optCode, String optName) {
        this.optType = optType;
        this.optCode = optCode;
        this.optName = optName;
    }

    public static ConditionOptEnum parseToEnum(String optCode) {
        if (ObjectUtil.isEmpty(optCode)) {
            return null;
        }
        for (ConditionOptEnum value : ConditionOptEnum.values()) {
            if (value.optCode.equals(optCode)) {
                return value;
            }
        }
        return null;
    }

}
