Class ImmutableTable.Builder<R,C,V>

java.lang.Object
com.google.common.collect.ImmutableTable.Builder<R,C,V>
Enclosing class:
ImmutableTable<R,C,V>

@DoNotMock public static final class ImmutableTable.Builder<R,C,V> extends Object
A builder for creating immutable table instances, especially public static final tables ("constant tables"). Example:
static final ImmutableTable<Integer, Character, String> SPREADSHEET =
    new ImmutableTable.Builder<Integer, Character, String>()
        .put(1, 'A', "foo")
        .put(1, 'B', "bar")
        .put(2, 'A', "baz")
        .buildOrThrow();

By default, the order in which cells are added to the builder determines the iteration ordering of all views in the returned table, with putAll(Table) following the Table.cellSet() iteration order. However, if orderRowsBy(Comparator) or orderColumnsBy(Comparator) is called, the views are sorted by the supplied comparators.

For empty or single-cell immutable tables, ImmutableTable.of() and ImmutableTable.of(Object, Object, Object) are even more convenient.

Builder instances can be reused - it is safe to call buildOrThrow() multiple times to build multiple tables in series. Each table is a superset of the tables created before it.

Since:
11.0
Author:
Gregory Kick