class AnswerMetadataUtil {

  @VisibleForTesting
  @Nonnull
  static Map<String, Map<Aggregation, Object>> computeColumnAggregations(
      @Nonnull TableAnswerElement table,
      @Nonnull List<ColumnAggregation> aggregations,
      @Nonnull BatfishLogger logger) {
    Map<String, Map<Aggregation, Object>> columnAggregations = new HashMap<>();
    aggregations.stream()
        .map(columnAggregation -> computeColumnAggregation(table, columnAggregation, logger))
        .filter(Objects::nonNull)
        .forEach(
            columnAggregationResult ->
                columnAggregations
                    .computeIfAbsent(columnAggregationResult.getColumn(), c -> new HashMap<>())
                    .computeIfAbsent(
                        columnAggregationResult.getAggregation(),
                        a -> columnAggregationResult.getValue()));
    return CollectionUtil.toImmutableMap(
        columnAggregations,
        Entry::getKey,
        columnAggregationsByColumnEntry ->
            CollectionUtil.toImmutableMap(
                columnAggregationsByColumnEntry.getValue(), Entry::getKey, Entry::getValue));
  }

  private  AnswerMetadataUtil();

}