Iterator<T> iterator = metrics.iterator();
T metric = iterator.next();
int scheduleId = metric.getScheduleId();
Double min = metric.getMin();
Double max = metric.getMax();
ArithmeticMeanCalculator mean = new ArithmeticMeanCalculator();
mean.add(metric.getAvg());
while (iterator.hasNext()) {
metric = iterator.next();
mean.add(metric.getAvg());
if (metric.getMin() < min) {
min = metric.getMin();
}
if (metric.getMax() > max) {
max = metric.getMax();
}
}
return new AggregateNumericMetric(scheduleId, bucket, mean.getArithmeticMean(), min, max, timeSlice);
}