package com.education.workflow;

import com.education.workflow.iface.IContext;
import com.education.workflow.iface.IContextCollector;
import org.springframework.stereotype.Component;

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

public abstract class DefContextCollector implements IContextCollector {

    protected  List<IContext> contexts = Collections.synchronizedList(new ArrayList<IContext>());

    protected String url;
    @Override
    public void setUrl(String url) {
       this.url = url;
    }

    @Override
    public List<IContext> collect() {
        this.contexts.addAll(this.doCollect());
        return contexts;
    }

    protected  abstract  List<IContext>  doCollect();

    @Override
    public void setContext(IContext context) {
     this.contexts.add(context);
    }
}
