package com.google.common.collect; import com.google.common.base.Function; import com.google.common.base.Objects; import com.google.common.base.Preconditions; import com.google.common.base.Supplier; import com.google.common.collect.Table; import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; /* loaded from: classes2.dex */ public final class Tables { private static final Function, ? extends Map> UNMODIFIABLE_WRAPPER = new Function, Map>() { // from class: com.google.common.collect.Tables.1 @Override // com.google.common.base.Function public Map apply(Map map) { return Collections.unmodifiableMap(map); } }; static /* synthetic */ Function access$000() { return unmodifiableWrapper(); } private Tables() { } public static Table.Cell immutableCell(R r, C c, V v) { return new ImmutableCell(r, c, v); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static final class ImmutableCell extends AbstractCell implements Serializable { private static final long serialVersionUID = 0; private final C columnKey; private final R rowKey; private final V value; ImmutableCell(R r, C c, V v) { this.rowKey = r; this.columnKey = c; this.value = v; } @Override // com.google.common.collect.Table.Cell public final V getValue() { return this.value; } @Override // com.google.common.collect.Table.Cell public final R getRowKey() { return this.rowKey; } @Override // com.google.common.collect.Table.Cell public final C getColumnKey() { return this.columnKey; } } /* loaded from: classes2.dex */ static abstract class AbstractCell implements Table.Cell { @Override // com.google.common.collect.Table.Cell public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Table.Cell)) { return false; } Table.Cell cell = (Table.Cell) obj; return Objects.equal(getRowKey(), cell.getRowKey()) && Objects.equal(getColumnKey(), cell.getColumnKey()) && Objects.equal(getValue(), cell.getValue()); } @Override // com.google.common.collect.Table.Cell public int hashCode() { return Objects.hashCode(getRowKey(), getColumnKey(), getValue()); } public String toString() { String valueOf = String.valueOf(getRowKey()); String valueOf2 = String.valueOf(getColumnKey()); String valueOf3 = String.valueOf(getValue()); StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 4 + String.valueOf(valueOf2).length() + String.valueOf(valueOf3).length()); sb.append("("); sb.append(valueOf); sb.append(","); sb.append(valueOf2); sb.append(")="); sb.append(valueOf3); return sb.toString(); } } public static Table transpose(Table table) { if (table instanceof TransposeTable) { return ((TransposeTable) table).original; } return new TransposeTable(table); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class TransposeTable extends AbstractTable { private static final Function, Table.Cell> TRANSPOSE_CELL = new Function, Table.Cell>() { // from class: com.google.common.collect.Tables.TransposeTable.1 @Override // com.google.common.base.Function public Table.Cell apply(Table.Cell cell) { return Tables.immutableCell(cell.getColumnKey(), cell.getRowKey(), cell.getValue()); } }; final Table original; TransposeTable(Table table) { this.original = (Table) Preconditions.checkNotNull(table); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public void clear() { this.original.clear(); } @Override // com.google.common.collect.Table public Map column(R r) { return this.original.row(r); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public Set columnKeySet() { return this.original.rowKeySet(); } @Override // com.google.common.collect.Table public Map> columnMap() { return this.original.rowMap(); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public boolean contains(Object obj, Object obj2) { return this.original.contains(obj2, obj); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public boolean containsColumn(Object obj) { return this.original.containsRow(obj); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public boolean containsRow(Object obj) { return this.original.containsColumn(obj); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public boolean containsValue(Object obj) { return this.original.containsValue(obj); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public V get(Object obj, Object obj2) { return this.original.get(obj2, obj); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public V put(C c, R r, V v) { return this.original.put(r, c, v); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public void putAll(Table table) { this.original.putAll(Tables.transpose(table)); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public V remove(Object obj, Object obj2) { return this.original.remove(obj2, obj); } @Override // com.google.common.collect.Table public Map row(C c) { return this.original.column(c); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public Set rowKeySet() { return this.original.columnKeySet(); } @Override // com.google.common.collect.Table public Map> rowMap() { return this.original.columnMap(); } @Override // com.google.common.collect.Table public int size() { return this.original.size(); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public Collection values() { return this.original.values(); } @Override // com.google.common.collect.AbstractTable Iterator> cellIterator() { return Iterators.transform(this.original.cellSet().iterator(), TRANSPOSE_CELL); } } public static Table newCustomTable(Map> map, Supplier> supplier) { Preconditions.checkArgument(map.isEmpty()); Preconditions.checkNotNull(supplier); return new StandardTable(map, supplier); } public static Table transformValues(Table table, Function function) { return new TransformedTable(table, function); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class TransformedTable extends AbstractTable { final Table fromTable; final Function function; TransformedTable(Table table, Function function) { this.fromTable = (Table) Preconditions.checkNotNull(table); this.function = (Function) Preconditions.checkNotNull(function); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public boolean contains(Object obj, Object obj2) { return this.fromTable.contains(obj, obj2); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public V2 get(Object obj, Object obj2) { if (contains(obj, obj2)) { return this.function.apply(this.fromTable.get(obj, obj2)); } return null; } @Override // com.google.common.collect.Table public int size() { return this.fromTable.size(); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public void clear() { this.fromTable.clear(); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public V2 put(R r, C c, V2 v2) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public void putAll(Table table) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public V2 remove(Object obj, Object obj2) { if (contains(obj, obj2)) { return this.function.apply(this.fromTable.remove(obj, obj2)); } return null; } @Override // com.google.common.collect.Table public Map row(R r) { return Maps.transformValues(this.fromTable.row(r), this.function); } @Override // com.google.common.collect.Table public Map column(C c) { return Maps.transformValues(this.fromTable.column(c), this.function); } Function, Table.Cell> cellFunction() { return new Function, Table.Cell>(this) { // from class: com.google.common.collect.Tables.TransformedTable.1 final TransformedTable this$0; { this.this$0 = this; } @Override // com.google.common.base.Function public Table.Cell apply(Table.Cell cell) { return Tables.immutableCell(cell.getRowKey(), cell.getColumnKey(), this.this$0.function.apply(cell.getValue())); } }; } @Override // com.google.common.collect.AbstractTable Iterator> cellIterator() { return Iterators.transform(this.fromTable.cellSet().iterator(), cellFunction()); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public Set rowKeySet() { return this.fromTable.rowKeySet(); } @Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table public Set columnKeySet() { return this.fromTable.columnKeySet(); } @Override // com.google.common.collect.AbstractTable Collection createValues() { return Collections2.transform(this.fromTable.values(), this.function); } @Override // com.google.common.collect.Table public Map> rowMap() { return Maps.transformValues(this.fromTable.rowMap(), new Function, Map>(this) { // from class: com.google.common.collect.Tables.TransformedTable.2 final TransformedTable this$0; { this.this$0 = this; } @Override // com.google.common.base.Function public Map apply(Map map) { return Maps.transformValues(map, this.this$0.function); } }); } @Override // com.google.common.collect.Table public Map> columnMap() { return Maps.transformValues(this.fromTable.columnMap(), new Function, Map>(this) { // from class: com.google.common.collect.Tables.TransformedTable.3 final TransformedTable this$0; { this.this$0 = this; } @Override // com.google.common.base.Function public Map apply(Map map) { return Maps.transformValues(map, this.this$0.function); } }); } } public static Table unmodifiableTable(Table table) { return new UnmodifiableTable(table); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public static class UnmodifiableTable extends ForwardingTable implements Serializable { private static final long serialVersionUID = 0; final Table delegate; UnmodifiableTable(Table table) { this.delegate = (Table) Preconditions.checkNotNull(table); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public Set> cellSet() { return Collections.unmodifiableSet(super.cellSet()); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public void clear() { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public Map column(C c) { return Collections.unmodifiableMap(super.column(c)); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public Set columnKeySet() { return Collections.unmodifiableSet(super.columnKeySet()); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public Map> columnMap() { return Collections.unmodifiableMap(Maps.transformValues(super.columnMap(), Tables.access$000())); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public V put(R r, C c, V v) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public void putAll(Table table) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public V remove(Object obj, Object obj2) { throw new UnsupportedOperationException(); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public Map row(R r) { return Collections.unmodifiableMap(super.row(r)); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public Set rowKeySet() { return Collections.unmodifiableSet(super.rowKeySet()); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public Map> rowMap() { return Collections.unmodifiableMap(Maps.transformValues(super.rowMap(), Tables.access$000())); } @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.Table public Collection values() { return Collections.unmodifiableCollection(super.values()); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.ForwardingTable, com.google.common.collect.ForwardingObject public Table delegate() { return this.delegate; } } public static RowSortedTable unmodifiableRowSortedTable(RowSortedTable rowSortedTable) { return new UnmodifiableRowSortedMap(rowSortedTable); } /* loaded from: classes2.dex */ static final class UnmodifiableRowSortedMap extends UnmodifiableTable implements RowSortedTable { private static final long serialVersionUID = 0; public UnmodifiableRowSortedMap(RowSortedTable rowSortedTable) { super(rowSortedTable); } /* JADX INFO: Access modifiers changed from: protected */ @Override // com.google.common.collect.Tables.UnmodifiableTable, com.google.common.collect.ForwardingTable, com.google.common.collect.ForwardingObject public final RowSortedTable delegate() { return (RowSortedTable) super.delegate(); } @Override // com.google.common.collect.Tables.UnmodifiableTable, com.google.common.collect.ForwardingTable, com.google.common.collect.Table public final SortedMap> rowMap() { return Collections.unmodifiableSortedMap(Maps.transformValues((SortedMap) delegate().rowMap(), Tables.access$000())); } @Override // com.google.common.collect.Tables.UnmodifiableTable, com.google.common.collect.ForwardingTable, com.google.common.collect.Table public final SortedSet rowKeySet() { return Collections.unmodifiableSortedSet(delegate().rowKeySet()); } } public static Table synchronizedTable(Table table) { return Synchronized.table(table, null); } /* JADX INFO: Access modifiers changed from: package-private */ public static boolean equalsImpl(Table table, Object obj) { if (obj == table) { return true; } if (obj instanceof Table) { return table.cellSet().equals(((Table) obj).cellSet()); } return false; } private static Function, Map> unmodifiableWrapper() { return (Function, Map>) UNMODIFIABLE_WRAPPER; } }