Browse Source

bug #I6JF0K 迭代&循环组件在SWITCH语境中无法获取迭代对象和下标的问题

everywhere.z 2 years ago
parent
commit
42948e8ac6

+ 16 - 8
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/LoopCondition.java

@@ -4,6 +4,8 @@ import com.yomahub.liteflow.flow.element.Chain;
 import com.yomahub.liteflow.flow.element.Executable;
 import com.yomahub.liteflow.flow.element.Node;
 
+import java.util.function.Consumer;
+
 /**
  * 循环Condition的抽象类
  * 主要继承对象有ForCondition和WhileCondition
@@ -26,10 +28,13 @@ public abstract class LoopCondition extends Condition {
     protected void setLoopIndex(Executable executableItem, int index){
         if (executableItem instanceof Chain){
             ((Chain)executableItem).getConditionList().forEach(condition -> setLoopIndex(condition, index));
-        }else if(executableItem instanceof IfCondition){
-            ((Condition)executableItem).getExecutableList().forEach(executable -> setLoopIndex(executable, index));
-            setLoopIndex(((IfCondition)executableItem).getTrueCaseExecutableItem(), index);
-            setLoopIndex(((IfCondition)executableItem).getFalseCaseExecutableItem(), index);
+        }else if(executableItem instanceof IfCondition) {
+            ((Condition) executableItem).getExecutableList().forEach(executable -> setLoopIndex(executable, index));
+            setLoopIndex(((IfCondition) executableItem).getTrueCaseExecutableItem(), index);
+            setLoopIndex(((IfCondition) executableItem).getFalseCaseExecutableItem(), index);
+        }else if(executableItem instanceof SwitchCondition){
+            ((Condition) executableItem).getExecutableList().forEach(executable -> setLoopIndex(executable, index));
+            ((SwitchCondition)executableItem).getTargetList().forEach(executable -> setLoopIndex(executableItem, index));
         }else if(executableItem instanceof Condition){
             ((Condition)executableItem).getExecutableList().forEach(executable -> setLoopIndex(executable, index));
         }else if(executableItem instanceof Node){
@@ -40,10 +45,13 @@ public abstract class LoopCondition extends Condition {
     protected void setCurrLoopObject(Executable executableItem, Object obj){
         if (executableItem instanceof Chain){
             ((Chain)executableItem).getConditionList().forEach(condition -> setCurrLoopObject(condition, obj));
-        }else if(executableItem instanceof IfCondition){
-            ((Condition)executableItem).getExecutableList().forEach(executable -> setCurrLoopObject(executable, obj));
-            setCurrLoopObject(((IfCondition)executableItem).getTrueCaseExecutableItem(), obj);
-            setCurrLoopObject(((IfCondition)executableItem).getFalseCaseExecutableItem(), obj);
+        }else if(executableItem instanceof IfCondition) {
+            ((Condition) executableItem).getExecutableList().forEach(executable -> setCurrLoopObject(executable, obj));
+            setCurrLoopObject(((IfCondition) executableItem).getTrueCaseExecutableItem(), obj);
+            setCurrLoopObject(((IfCondition) executableItem).getFalseCaseExecutableItem(), obj);
+        }else if(executableItem instanceof SwitchCondition){
+            ((Condition) executableItem).getExecutableList().forEach(executable -> setCurrLoopObject(executable, obj));
+            ((SwitchCondition)executableItem).getTargetList().forEach(executable -> setCurrLoopObject(executableItem, obj));
         }else if(executableItem instanceof Condition){
             ((Condition)executableItem).getExecutableList().forEach(executable -> setCurrLoopObject(executable, obj));
         }else if(executableItem instanceof Node){