enhancement #IB1YLX 简化规则中的注释,化繁为简

This commit is contained in:
everywhere.z
2024-11-04 17:01:01 +08:00
parent 86905ee771
commit 38ed6fec0e
4 changed files with 5 additions and 24 deletions

View File

@@ -263,8 +263,6 @@ public class LiteFlowChainELBuilder {
public static ValidationResp validateWithEx(String elStr) {
ValidationResp resp = new ValidationResp();
try {
// 移除注释
elStr = ElRegexUtil.removeComments(elStr);
LiteFlowChainELBuilder.createChain().setEL(elStr);
resp.setSuccess(true);
} catch (Exception e) {

View File

@@ -352,21 +352,21 @@ public class ParserHelper {
// 如果有route这个标签说明是决策表chain
// 决策表链路必须有route和body这两个标签
if (routeElement != null){
builder.setRoute(ElRegexUtil.removeComments(routeElement.getText()));
builder.setRoute(routeElement.getText());
Element bodyElement = e.element(BODY);
if (bodyElement == null){
String errMsg = StrUtil.format("If you have defined the tag <route>, then you must define the tag <body> in chain[{}]", chainId);
throw new FlowSystemException(errMsg);
}
builder.setEL(ElRegexUtil.removeComments(bodyElement.getText()));
builder.setEL(bodyElement.getText());
}else{
// 即使没有route这个标签body标签单独写也是被允许的
Element bodyElement = e.element(BODY);
if (bodyElement != null){
builder.setEL(ElRegexUtil.removeComments(bodyElement.getText()));
builder.setEL(bodyElement.getText());
}else{
builder.setEL(ElRegexUtil.removeComments(e.getText()));
builder.setEL(e.getText());
}
}

View File

@@ -21,23 +21,6 @@ public class ElRegexUtil {
// abstractChain 占位符正则表达式
private static final String REGEX_ABSTRACT_HOLDER = "\\{\\{\\s*([a-zA-Z_][a-zA-Z_\\d]*|\\d+)\\s*\\}\\}(?![\\s]*=)";
/**
* 移除 el 表达式中的注释,支持 java 的注释,包括单行注释、多行注释, 会压缩字符串,移除空格和换行符
*
* @param elStr el 表达式
* @return 移除注释后的 el 表达式
*/
public static String removeComments(String elStr) {
if (StrUtil.isBlank(elStr)) {
return elStr;
}
return Pattern.compile(REGEX_COMMENT)
.matcher(elStr)
// 移除注释
.replaceAll(CharSequenceUtil.EMPTY);
}
/**
* 根据抽象EL和实现EL替换抽象EL中的占位符
*

View File

@@ -39,7 +39,7 @@
</scm>
<properties>
<revision>2.12.4.1</revision>
<revision>2.12.4.2</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>8</maven.compiler.source>