Did you consider passing in a separate Metric object into the aggregate() method? That would simplify some of the logic for aggregate.