com.google.common.collect
Class Tables

java.lang.Object
  extended by com.google.common.collect.Tables

@GwtCompatible
@Beta
public final class Tables
extends Object

Provides static methods that involve a Table.

Since:
7
Author:
Jared Levy

Method Summary
static
<R,C,V> Table.Cell<R,C,V>
immutableCell(R rowKey, C columnKey, V value)
          Returns an immutable cell with the specified row key, column key, and value.
static
<R,C,V> Table<C,R,V>
transpose(Table<R,C,V> table)
          Creates a transposed view of a given table that flips its row and column keys.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

immutableCell

public static <R,C,V> Table.Cell<R,C,V> immutableCell(@Nullable
                                                      R rowKey,
                                                      @Nullable
                                                      C columnKey,
                                                      @Nullable
                                                      V value)
Returns an immutable cell with the specified row key, column key, and value.

The returned cell is serializable.

Parameters:
rowKey - the row key to be associated with the returned cell
columnKey - the column key to be associated with the returned cell
value - the value to be associated with the returned cell

transpose

public static <R,C,V> Table<C,R,V> transpose(Table<R,C,V> table)
Creates a transposed view of a given table that flips its row and column keys. In other words, calling get(columnKey, rowKey) on the generated table always returns the same value as calling get(rowKey, columnKey) on the original table. Updating the original table changes the contents of the transposed table and vice versa.

The returned table supports update operations as long as the input table supports the analogous operation with swapped rows and columns. For example, in a HashBasedTable instance, rowKeySet().iterator() supports remove() but columnKeySet().iterator() doesn't. With a transposed HashBasedTable, it's the other way around.