List of usage examples for com.google.common.collect ImmutableTable columnMap
@Override public abstract ImmutableMap<C, Map<R, V>> columnMap();
The value Map From source file:google.registry.tools.server.ListObjectsAction.javaUsage
/**
* Computes the column widths of the given table of strings column-keyed by strings and returns
* them as a map from column key name to integer width. The column width is defined as the max
* length of any string in that column, including the name of the column.
*//* w ww.j av a2 s . c o m*/
private static ImmutableMap<String, Integer> computeColumnWidths(ImmutableTable<?, String, String> data,
final boolean includingHeader) {
return ImmutableMap.copyOf(Maps.transformEntries(data.columnMap(),
new Maps.EntryTransformer<String, Map<?, String>, Integer>() {
@Override
public Integer transformEntry(String columnName, Map<?, String> columnValues) {
// Return the length of the longest string in this column (including the column name).
return Ordering.natural()
.max(Iterables.transform(
Iterables.concat(ImmutableList.of(includingHeader ? columnName : ""),
columnValues.values()),
new Function<String, Integer>() {
@Override
public Integer apply(String value) {
return value.length();
}
}));
}
}));
}