@Test public void testComputeColumnAggregationMax() { String columnName = "col"; int value = 5; TableAnswerElement table = new TableAnswerElement( new TableMetadata( ImmutableList.of(new ColumnMetadata(columnName, Schema.INTEGER, "foobar")), new DisplayHints().getTextDesc())) .addRow(Row.of(columnName, value)) .addRow(Row.of(columnName, 2)); ColumnAggregation columnAggregation = new ColumnAggregation(Aggregation.MAX, columnName); assertThat( AnswerMetadataUtil.computeColumnAggregation(table, columnAggregation, _logger), equalTo(new ColumnAggregationResult(Aggregation.MAX, columnName, value))); }
@VisibleForTesting @Nullable static ColumnAggregationResult computeColumnAggregation( @Nonnull TableAnswerElement table, @Nonnull ColumnAggregation columnAggregation, @Nonnull BatfishLogger logger) { Object value; String column = columnAggregation.getColumn(); Aggregation aggregation = columnAggregation.getAggregation(); switch (aggregation) { case MAX: value = computeColumnMax(table, column, logger); break; default: String message = String.format("Unhandled aggregation type: %s", aggregation); logger.errorf("%s\n", message); throw new IllegalArgumentException(message); } return value == null ? null : new ColumnAggregationResult(aggregation, column, value); }
AnswerMetadataUtil { @VisibleForTesting @Nullable static ColumnAggregationResult computeColumnAggregation( @Nonnull TableAnswerElement table, @Nonnull ColumnAggregation columnAggregation, @Nonnull BatfishLogger logger) { Object value; String column = columnAggregation.getColumn(); Aggregation aggregation = columnAggregation.getAggregation(); switch (aggregation) { case MAX: value = computeColumnMax(table, column, logger); break; default: String message = String.format("Unhandled aggregation type: %s", aggregation); logger.errorf("%s\n", message); throw new IllegalArgumentException(message); } return value == null ? null : new ColumnAggregationResult(aggregation, column, value); } }
AnswerMetadataUtil { @VisibleForTesting @Nullable static ColumnAggregationResult computeColumnAggregation( @Nonnull TableAnswerElement table, @Nonnull ColumnAggregation columnAggregation, @Nonnull BatfishLogger logger) { Object value; String column = columnAggregation.getColumn(); Aggregation aggregation = columnAggregation.getAggregation(); switch (aggregation) { case MAX: value = computeColumnMax(table, column, logger); break; default: String message = String.format("Unhandled aggregation type: %s", aggregation); logger.errorf("%s\n", message); throw new IllegalArgumentException(message); } return value == null ? null : new ColumnAggregationResult(aggregation, column, value); } private  AnswerMetadataUtil(); }
AnswerMetadataUtil { @VisibleForTesting @Nullable static ColumnAggregationResult computeColumnAggregation( @Nonnull TableAnswerElement table, @Nonnull ColumnAggregation columnAggregation, @Nonnull BatfishLogger logger) { Object value; String column = columnAggregation.getColumn(); Aggregation aggregation = columnAggregation.getAggregation(); switch (aggregation) { case MAX: value = computeColumnMax(table, column, logger); break; default: String message = String.format("Unhandled aggregation type: %s", aggregation); logger.errorf("%s\n", message); throw new IllegalArgumentException(message); } return value == null ? null : new ColumnAggregationResult(aggregation, column, value); } private  AnswerMetadataUtil(); static @Nonnull AnswerMetadata computeAnswerMetadata(
      @Nonnull Answer answer, @Nonnull BatfishLogger logger); }
AnswerMetadataUtil { @VisibleForTesting @Nullable static ColumnAggregationResult computeColumnAggregation( @Nonnull TableAnswerElement table, @Nonnull ColumnAggregation columnAggregation, @Nonnull BatfishLogger logger) { Object value; String column = columnAggregation.getColumn(); Aggregation aggregation = columnAggregation.getAggregation(); switch (aggregation) { case MAX: value = computeColumnMax(table, column, logger); break; default: String message = String.format("Unhandled aggregation type: %s", aggregation); logger.errorf("%s\n", message); throw new IllegalArgumentException(message); } return value == null ? null : new ColumnAggregationResult(aggregation, column, value); } private  AnswerMetadataUtil(); static @Nonnull AnswerMetadata computeAnswerMetadata(
      @Nonnull Answer answer, @Nonnull BatfishLogger logger);  }