enhancement #I5OFMU 优化 Operator 代码

This commit is contained in:
tangkc
2022-09-07 11:18:50 +08:00
parent eb76825e9f
commit 37c9666aee

View File

@@ -1,42 +1,30 @@
package com.yomahub.liteflow.builder.el.operator;
import com.ql.util.express.Operator;
import com.ql.util.express.exception.QLException;
import com.yomahub.liteflow.exception.ELParseException;
import com.yomahub.liteflow.builder.el.operator.base.BaseOperator;
import com.yomahub.liteflow.builder.el.operator.base.OperatorHelper;
import com.yomahub.liteflow.flow.element.Executable;
import com.yomahub.liteflow.flow.element.condition.WhenCondition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* EL规则中的WHEN的操作符
* @author Bryan.Zhang
* @since 2.8.0
*/
public class WhenOperator extends Operator {
private final Logger LOG = LoggerFactory.getLogger(this.getClass());
public class WhenOperator extends BaseOperator {
@Override
public WhenCondition executeInner(Object[] objects) throws Exception {
try {
if (objects.length == 0) {
throw new QLException("parameter is empty");
}
public Object buildCondition(Object[] objects) throws Exception {
OperatorHelper.checkObjectSizeGtZero(objects);
WhenCondition whenCondition = new WhenCondition();
for (Object obj : objects) {
if (obj instanceof Executable) {
whenCondition.addExecutable((Executable) obj);
} else {
throw new QLException("parameter must be executable item");
}
WhenCondition whenCondition = new WhenCondition();
for (Object obj : objects) {
if (obj instanceof Executable) {
whenCondition.addExecutable((Executable) obj);
} else {
throw new QLException("parameter must be executable item");
}
return whenCondition;
}catch (QLException e){
throw e;
}catch (Exception e){
throw new ELParseException("errors occurred in EL parsing");
}
return whenCondition;
}
}