package com.elab.core.async;

import com.elab.core.async.model.TaskStoreData;

import java.util.List;

/**
 * 集合处理
 *
 * @author ： liukx
 * @time ： 2020/8/6 -14:19
 */
public class ListTaskProcess implements TaskStoreProcess {

    private List<TaskStoreProcess> taskStoreProcesses;

    public ListTaskProcess(List<TaskStoreProcess> taskStoreProcesses) {
        this.taskStoreProcesses = taskStoreProcesses;
    }

    @Override
    public void add(TaskStoreData taskStoreData) {
        for (int i = 0; i < taskStoreProcesses.size(); i++) {
            TaskStoreProcess taskStoreProcess = taskStoreProcesses.get(i);
            taskStoreProcess.add(taskStoreData);
        }
    }

    @Override
    public void success(TaskStoreData taskStoreData) {
        for (int i = 0; i < taskStoreProcesses.size(); i++) {
            TaskStoreProcess taskStoreProcess = taskStoreProcesses.get(i);
            taskStoreProcess.success(taskStoreData);
        }
    }

    @Override
    public void error(TaskStoreData taskStoreData) {
        for (int i = 0; i < taskStoreProcesses.size(); i++) {
            TaskStoreProcess taskStoreProcess = taskStoreProcesses.get(i);
            taskStoreProcess.error(taskStoreData);
        }
    }
}
