/** Returns an immutable table containing a single cell. */ public static <R, C, V> ImmutableTable<R, C, V> of(R rowKey, C columnKey, V value) { return new SingletonImmutableTable<>(rowKey, columnKey, value); }
@Override public ImmutableMap<R, V> column(C columnKey) { checkNotNull(columnKey); return containsColumn(columnKey) ? ImmutableMap.of(singleRowKey, singleValue) : ImmutableMap.<R, V>of(); }
@Override ImmutableSet<Cell<R, C, V>> createCellSet() { return ImmutableSet.of(cellOf(singleRowKey, singleColumnKey, singleValue)); }
@Override public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { return containsRow(rowKey) && containsColumn(columnKey); }
@Override public ImmutableMap<C, V> row(R rowKey) { checkNotNull(rowKey); return containsRow(rowKey) ? ImmutableMap.of(singleColumnKey, singleValue) : ImmutableMap.<C, V>of(); }
@Override public V get(@Nullable Object rowKey, @Nullable Object columnKey) { return contains(rowKey, columnKey) ? singleValue : null; }
@Override public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) { return containsRow(rowKey) && containsColumn(columnKey); }
@Override public ImmutableMap<C, V> row(R rowKey) { checkNotNull(rowKey); return containsRow(rowKey) ? ImmutableMap.of(singleColumnKey, singleValue) : ImmutableMap.<C, V>of(); }
@Override public V get(@Nullable Object rowKey, @Nullable Object columnKey) { return contains(rowKey, columnKey) ? singleValue : null; }
/** Returns an immutable table containing a single cell. */ public static <R, C, V> ImmutableTable<R, C, V> of(R rowKey, C columnKey, V value) { return new SingletonImmutableTable<>(rowKey, columnKey, value); }
@Override public ImmutableMap<R, V> column(C columnKey) { checkNotNull(columnKey); return containsColumn(columnKey) ? ImmutableMap.of(singleRowKey, singleValue) : ImmutableMap.<R, V>of(); }
@Override ImmutableSet<Cell<R, C, V>> createCellSet() { return ImmutableSet.of(cellOf(singleRowKey, singleColumnKey, singleValue)); }
/** * Returns a newly-created immutable table. * * @throws IllegalArgumentException if duplicate key pairs were added */ public ImmutableTable<R, C, V> build() { int size = cells.size(); switch (size) { case 0: return of(); case 1: return new SingletonImmutableTable<>(Iterables.getOnlyElement(cells)); default: return RegularImmutableTable.forCells(cells, rowComparator, columnComparator); } } }
@Override public ImmutableMap<R, V> column(C columnKey) { checkNotNull(columnKey); return containsColumn(columnKey) ? ImmutableMap.of(singleRowKey, singleValue) : ImmutableMap.<R, V>of(); }
@Override ImmutableSet<Cell<R, C, V>> createCellSet() { return ImmutableSet.of(cellOf(singleRowKey, singleColumnKey, singleValue)); }
public static SingletonImmutableTable<Object, Object, Object> instantiate( SerializationStreamReader reader) throws SerializationException { Object rowKey = reader.readObject(); Object columnKey = reader.readObject(); Object value = reader.readObject(); return new SingletonImmutableTable<>(rowKey, columnKey, value); }
@Override public ImmutableMap<R, V> column(C columnKey) { checkNotNull(columnKey); return containsColumn(columnKey) ? ImmutableMap.of(singleRowKey, singleValue) : ImmutableMap.<R, V>of(); }
@Override ImmutableSet<Cell<R, C, V>> createCellSet() { return ImmutableSet.of( cellOf(singleRowKey, singleColumnKey, singleValue)); }
/** * Returns a newly-created immutable table. * * @throws IllegalArgumentException if duplicate key pairs were added */ public ImmutableTable<R, C, V> build() { int size = cells.size(); switch (size) { case 0: return of(); case 1: return new SingletonImmutableTable<>(Iterables.getOnlyElement(cells)); default: return RegularImmutableTable.forCells(cells, rowComparator, columnComparator); } } }
@Override public ImmutableMap<R, V> column(C columnKey) { checkNotNull(columnKey); return containsColumn(columnKey) ? ImmutableMap.of(singleRowKey, singleValue) : ImmutableMap.<R, V>of(); }