package leigh.astro.fits;

import java.util.HashMap;
import java.util.List;

/**
 * This class counts unique exposures in a given set.
 *
 * @author Alex Leigh
 */
public class ExposureCounter {
    private HashMap<Exposure, Integer> counter = new HashMap<>();

    public void count(List<AstroSub> subs) {
        for (AstroSub sub : subs) {
            Integer cnt = counter.get(sub.getExposure());
            if (cnt == null) {
                counter.put(sub.getExposure(), 1);
            } else {
                counter.put(sub.getExposure(), cnt + 1);
            }
        }
    }

    public int getCount(Exposure exp) {
        Integer cnt = counter.get(exp);
        if (cnt == null) return 0;
        return cnt;
    }

    @Override
    public String toString() {
        return "FilterCounter{" +
                "counter=" + counter +
                '}';
    }
}
