class LoopCondition extends Condition {
    //判断循环是否并行执行，默认为false
    private boolean parallel = false;

    protected Executable getBreakItem() {
        return this.getExecutableOne(ConditionKey.BREAK_KEY);
    }

    public void setBreakItem(Executable breakNode) {
        this.addExecutable(ConditionKey.BREAK_KEY, breakNode);
    }

    protected Executable getDoExecutor() {
        return this.getExecutableOne(ConditionKey.DO_KEY);
    }

    public void setDoExecutor(Executable executable) {
        this.addExecutable(ConditionKey.DO_KEY, executable);
    }

    protected void setLoopIndex(Executable executableItem, int index) {
        if (executableItem instanceof Chain) {
            ((Chain) executableItem).getConditionList().forEach(condition -> setLoopIndex(condition, index));
        } else if (executableItem instanceof Condition) {
            ((Condition) executableItem).getExecutableGroup()
                    .forEach((key, value) -> value.forEach(executable -> setLoopIndex(executable, index)));
        } else if (executableItem instanceof Node) {
            ((Node) executableItem).setLoopIndex(index);
        }
    }

    protected void setCurrLoopObject(Executable executableItem, Object obj) {<FILL_FUNCTION_BODY>}

    protected void removeLoopIndex(Executable executableItem) {
        if (executableItem instanceof Chain) {
            ((Chain) executableItem).getConditionList().forEach(this::removeLoopIndex);
        } else if (executableItem instanceof Condition) {
            ((Condition) executableItem).getExecutableGroup()
                    .forEach((key, value) -> value.forEach(this::removeLoopIndex));
        } else if (executableItem instanceof Node) {
            ((Node) executableItem).removeLoopIndex();
        }
    }

    protected void removeCurrLoopObject(Executable executableItem) {
        if (executableItem instanceof Chain) {
            ((Chain) executableItem).getConditionList().forEach(this::removeCurrLoopObject);
        } else if (executableItem instanceof Condition) {
            ((Condition) executableItem).getExecutableGroup()
                    .forEach((key, value) -> value.forEach(this::removeCurrLoopObject));
        } else if (executableItem instanceof Node) {
            ((Node) executableItem).removeCurrLoopObject();
        }
    }

    public boolean isParallel() {
        return parallel;
    }

    public void setParallel(boolean parallel) {
        this.parallel = parallel;
    }

    //循环并行执行的futureList处理
    protected void handleFutureList(List<CompletableFuture<LoopFutureObj>> futureList)throws Exception{
        CompletableFuture<?> resultCompletableFuture = CompletableFuture.allOf(futureList.toArray(new CompletableFuture[]{}));
        resultCompletableFuture.get();
        //获取所有的执行结果,如果有失败的，那么需要抛出异常
        for (CompletableFuture<LoopFutureObj> future : futureList) {
            LoopFutureObj loopFutureObj = future.get();
            if (!loopFutureObj.isSuccess()) {
                throw loopFutureObj.getEx();
            }
        }
    }

    // 循环并行执行的Supplier封装
    public class LoopParallelSupplier implements Supplier<LoopFutureObj> {
        private final Executable executableItem;
        private final String currChainId;
        private final Integer slotIndex;
        private final Integer loopIndex;
        private final Object itObj;

        public LoopParallelSupplier(Executable executableItem, String currChainId, Integer slotIndex, Integer loopIndex) {
            this.executableItem = executableItem;
            this.currChainId = currChainId;
            this.slotIndex = slotIndex;
            this.loopIndex = loopIndex;
            this.itObj = null;
        }

        public LoopParallelSupplier(Executable executableItem, String currChainId, Integer slotIndex, Integer loopIndex, Object itObj) {
            this.executableItem = executableItem;
            this.currChainId = currChainId;
            this.slotIndex = slotIndex;
            this.loopIndex = loopIndex;
            this.itObj = itObj;
        }


        @Override
        public LoopFutureObj get() {
            try {
                executableItem.setCurrChainId(this.currChainId);
                // 设置循环index
                setLoopIndex(executableItem, loopIndex);
                //IteratorCondition的情况下，需要设置当前循环对象
                if(itObj != null){
                    setCurrLoopObject(executableItem, itObj);
                }
                executableItem.execute(slotIndex);
                return LoopFutureObj.success(executableItem.getId());
            } catch (Exception e) {
                return LoopFutureObj.fail(executableItem.getId(), e);
            }
        }
    }

}

        if (executableItem instanceof Chain) {
            ((Chain) executableItem).getConditionList().forEach(condition -> setCurrLoopObject(condition, obj));
        } else if (executableItem instanceof Condition) {
            ((Condition) executableItem).getExecutableGroup()
                    .forEach((key, value) -> value.forEach(executable -> setCurrLoopObject(executable, obj)));
        } else if (executableItem instanceof Node) {
            ((Node) executableItem).setCurrLoopObject(obj);
        }
    
<methods>public non-sealed void <init>() ,public void addExecutable(com.yomahub.liteflow.flow.element.Executable) ,public void addExecutable(java.lang.String, com.yomahub.liteflow.flow.element.Executable) ,public void execute(java.lang.Integer) throws java.lang.Exception,public abstract void executeCondition(java.lang.Integer) throws java.lang.Exception,public List<com.yomahub.liteflow.flow.element.Node> getAllNodeInCondition() ,public abstract com.yomahub.liteflow.enums.ConditionTypeEnum getConditionType() ,public java.lang.String getCurrChainId() ,public java.lang.String getCurrChainName() ,public Map<java.lang.String,List<com.yomahub.liteflow.flow.element.Executable>> getExecutableGroup() ,public List<com.yomahub.liteflow.flow.element.Executable> getExecutableList() ,public List<com.yomahub.liteflow.flow.element.Executable> getExecutableList(java.lang.String) ,public com.yomahub.liteflow.flow.element.Executable getExecutableOne(java.lang.String) ,public com.yomahub.liteflow.enums.ExecuteableTypeEnum getExecuteType() ,public java.lang.String getId() ,public java.lang.String getTag() ,public void setCurrChainId(java.lang.String) ,public void setExecutableList(List<com.yomahub.liteflow.flow.element.Executable>) ,public void setId(java.lang.String) ,public void setTag(java.lang.String) <variables>private java.lang.String currChainId,private final Map<java.lang.String,List<com.yomahub.liteflow.flow.element.Executable>> executableGroup,private java.lang.String id,private java.lang.String tag