package cn.axzo.workflow.core.service.support.forecast.impl;

import cn.axzo.workflow.core.service.support.forecast.AbstractForecast;
import org.flowable.bpmn.model.EndEvent;
import org.flowable.bpmn.model.FlowElement;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Collections;
import java.util.List;

/**
 * 结束节点
 *
 * @author wangli
 * @since 2023/10/10 18:58
 */
@Component
public class EndEventForecasting extends AbstractForecast<EndEvent> {
    @Override
    public Boolean support(FlowElement flowElement) {
        return flowElement instanceof EndEvent;
    }

    @Override
    protected List<? extends FlowElement> getOutgoing(EndEvent flowElement) {
        return flowElement.getOutgoingFlows();
    }

    @Override
    public List<? extends FlowElement> calcRealOutgoingNodes(List<EndEvent> flowElements, String processInstanceId) {
        if (CollectionUtils.isEmpty(flowElements)) {
            return Collections.emptyList();
        }
        return super.calcRealOutgoingNodes(flowElements, processInstanceId);
    }
}
