package com.ruoyi.project.business.enums;


import com.ruoyi.common.exception.ServiceErrorException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author jubs
 */

@AllArgsConstructor
@Getter
public enum JEPLogicEnum {

    /**
     * 并且
     */
    AND("AND", "&&"),
    /**
     * if 函数
     */
    OR("OR", "||"),
    ;


    private String logicKey;
    private String logicValue;

    public static JEPLogicEnum fromByValue(String value) {
        for (JEPLogicEnum auditFlowEnum : values()) {
            if (auditFlowEnum.getLogicValue().equals(value)) {
                return auditFlowEnum;
            }
        }
        throw new ServiceErrorException("非法的逻辑判断类型");
    }

    public static JEPLogicEnum fromByKey(String key) {
        for (JEPLogicEnum auditFlowEnum : values()) {
            if (auditFlowEnum.getLogicKey().equals(key)) {
                return auditFlowEnum;
            }
        }
        throw new ServiceErrorException("非法的逻辑判断类型");
    }

}
