package com.ycwl.basic.videoTask.chains;

import com.ycwl.basic.videoTask.chains.interceptor.IVidTaskGenChainInterceptor;
import com.ycwl.basic.videoTask.entity.VideoTaskGeneratorContext;

import java.util.ArrayList;
import java.util.List;

public class VideoTaskGeneratorChain {
    private final List<IVidTaskGenChainInterceptor> interceptors = new ArrayList<>();
    private int index = 0;

    public void addInterceptor(IVidTaskGenChainInterceptor interceptor) {
        interceptors.add(interceptor);
    }

    public void process(VideoTaskGeneratorContext context) {
        if (index < interceptors.size()) {
            interceptors.get(index++).process(context, this);
        }
    }
}
