class AggregatorFactory {

    public Aggregator get(AggregationParameters parameters) {

        // return empty aggregator if empty
        if (parameters.getOperations().isEmpty() || parameters.getGroupBy().isEmpty()) {
            throw new IllegalArgumentException("Invalid aggregation parameters");
        }

        final AggregationOperation operation = parameters.getOperations().get(0);
        String groupBy = parameters.getGroupBy().get(0);

        switch (operation.getOperator()) {
        case AVERAGE:
            return new Average(groupBy, operation.getColumnId());
        case MIN:
            return new Min(groupBy, operation.getColumnId());
        case MAX:
            return new Max(groupBy, operation.getColumnId());
        case SUM:
            return new Sum(groupBy, operation.getColumnId());
        default:
            throw new IllegalArgumentException("Operation '" + operation.getOperator() + "' not supported");
        }
    }

}