From 37c9666aee1d7eac329539234f9015d84c27e997 Mon Sep 17 00:00:00 2001 From: tangkc <1016771049@qq.com> Date: Wed, 7 Sep 2022 11:18:50 +0800 Subject: [PATCH] =?UTF-8?q?enhancement=20#I5OFMU=20=E4=BC=98=E5=8C=96=20Op?= =?UTF-8?q?erator=20=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../builder/el/operator/WhenOperator.java | 36 +++++++------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java b/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java index 65f577b20..00e289b0b 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java @@ -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; } }