!137 添加验证EL规则的api,供检查之用

Merge pull request !137 from zendwang/dev
This commit is contained in:
铂赛东
2022-11-30 09:16:16 +00:00
committed by Gitee
3 changed files with 48 additions and 2 deletions

View File

@@ -14,12 +14,12 @@ import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.flow.element.Chain;
import com.yomahub.liteflow.flow.element.Executable;
import com.yomahub.liteflow.flow.element.condition.*;
import com.yomahub.liteflow.script.ScriptBeanManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.BiConsumer;
/**
* Chain基于代码形式的组装器
@@ -30,6 +30,9 @@ import java.util.function.BiConsumer;
*/
public class LiteFlowChainELBuilder {
private static final Logger LOG = LoggerFactory.getLogger(LiteFlowChainELBuilder.class);
private Chain chain;
/**
@@ -169,6 +172,21 @@ public class LiteFlowChainELBuilder {
}
}
/**
* EL表达式校验
* @param elStr EL表达式
* @return true 校验成功 false 校验失败
*/
public Boolean validate(String elStr) {
try {
this.setEL(elStr);
return Boolean.TRUE;
} catch (ELParseException e) {
LOG.error(e.getMessage());
}
return Boolean.FALSE;
}
public void build() {
this.chain.setConditionList(this.conditionList);
this.chain.setPreConditionList(this.preConditionList);