com.neko233.toolchain.common.approvalChain.AbstractApprovalChain Maven / Gradle / Ivy
package com.neko233.toolchain.common.approvalChain;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/**
* 【审批链】只会有一个节点处理生效
*
* @author SolarisNeko
* Date on 2022-12-15
*/
public abstract class AbstractApprovalChain {
private final List> pipeline = new CopyOnWriteArrayList<>();
public OUTPUT handle(INPUT input) {
for (ApprovalChainNode node : pipeline) {
if (node.isItHandle()) {
return node.handle(input);
}
}
return null;
}
public AbstractApprovalChain addPipelineNode(ApprovalChainNode node) {
this.pipeline.add(node);
return this;
}
public AbstractApprovalChain removePipelineNode(ApprovalChainNode node) {
this.pipeline.remove(node);
return this;
}
}