/* * The Broad Institute * SOFTWARE COPYRIGHT NOTICE AGREEMENT * This software and its documentation are copyright 2009 by the * Broad Institute/Massachusetts Institute of Technology. All rights are reserved. * * This software is supplied without any warranty or guaranteed support whatsoever. Neither * the Broad Institute nor MIT can be responsible for its use, misuse, or functionality. */ package edu.mit.broad.picard.metrics; import edu.mit.broad.sam.SAMRecord; public class AggregateMetricCollector implements MetricCollector { private final MetricCollector[] collectors; public AggregateMetricCollector(MetricCollector... collectors) { if (collectors.length == 0) { throw new IllegalArgumentException("Must supply at least one collector."); } this.collectors = collectors; } @Override public void addRecord(SAMRecord record) { for (MetricCollector collector : this.collectors) { collector.addRecord(record); } } @Override public void onComplete() { for (MetricCollector collector : this.collectors) { collector.onComplete(); } } @Override public void setMetrics(T metrics) { for (MetricCollector collector : this.collectors) { collector.setMetrics(metrics); } } @Override public T getMetrics() { return this.collectors[0].getMetrics(); } }