Example usage for com.google.common.collect ImmutableTable rowMap

List of usage examples for com.google.common.collect ImmutableTable rowMap

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableTable rowMap.

Prototype

@Override
public abstract ImmutableMap<R, Map<C, V>> rowMap();

Source Link

Document

The value Map instances in the returned map are ImmutableMap instances as well.

Usage

From source file:blue.lapis.methodremapper.Remapper.java

/**
 * Creates a new {@link Remapper} instance using the specified provider and
 * mappings.//from w  ww  . j a v  a  2s. c o  m
 *
 * @param provider The provider of the classes that will be scanned
 * @param mappings The method mappings to use
 */
public Remapper(ClassProvider provider, ImmutableTable<String, String, String> mappings) {
    this.provider = checkNotNull(provider, "provider");
    this.classes = Maps.newHashMap(mappings.rowMap());
}

From source file:google.registry.tools.server.ListObjectsAction.java

/** Converts the provided table of data to text, formatted using the provided column widths. */
private List<String> generateFormattedData(ImmutableTable<T, String, String> data,
        ImmutableMap<String, Integer> columnWidths) {
    Function<Map<String, String>, String> rowFormatter = makeRowFormatter(columnWidths);
    List<String> lines = new ArrayList<>();

    if (isHeaderRowInUse(data)) {
        // Add a row of headers (column names mapping to themselves).
        Map<String, String> headerRow = Maps.asMap(data.columnKeySet(), Functions.<String>identity());
        lines.add(rowFormatter.apply(headerRow));

        // Add a row of separator lines (column names mapping to '-' * column width).
        Map<String, String> separatorRow = Maps.transformValues(columnWidths, new Function<Integer, String>() {
            @Override//from  ww  w . j ava2s  .c o  m
            public String apply(Integer width) {
                return Strings.repeat("-", width);
            }
        });
        lines.add(rowFormatter.apply(separatorRow));
    }

    // Add the actual data rows.
    for (Map<String, String> row : data.rowMap().values()) {
        lines.add(rowFormatter.apply(row));
    }

    return lines;
}