package com.google.common.collect; import com.google.common.collect.Table; import com.google.errorprone.annotations.concurrent.LazyInit; import java.util.AbstractCollection; import java.util.AbstractSet; import java.util.Collection; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.annotation.CheckForNull; @ElementTypesAreNonnullByDefault /* loaded from: classes3.dex */ abstract class AbstractTable implements Table { @CheckForNull @LazyInit private transient Set> cellSet; @CheckForNull @LazyInit private transient Collection values; abstract Iterator> cellIterator(); @Override // com.google.common.collect.Table public boolean containsRow(@CheckForNull Object obj) { return Maps.safeContainsKey(rowMap(), obj); } @Override // com.google.common.collect.Table public boolean containsColumn(@CheckForNull Object obj) { return Maps.safeContainsKey(columnMap(), obj); } @Override // com.google.common.collect.Table public Set rowKeySet() { return rowMap().keySet(); } @Override // com.google.common.collect.Table public Set columnKeySet() { return columnMap().keySet(); } @Override // com.google.common.collect.Table public boolean containsValue(@CheckForNull Object obj) { Iterator> it = rowMap().values().iterator(); while (it.hasNext()) { if (it.next().containsValue(obj)) { return true; } } return false; } @Override // com.google.common.collect.Table public boolean contains(@CheckForNull Object obj, @CheckForNull Object obj2) { Map map = (Map) Maps.safeGet(rowMap(), obj); return map != null && Maps.safeContainsKey(map, obj2); } @Override // com.google.common.collect.Table @CheckForNull public V get(@CheckForNull Object obj, @CheckForNull Object obj2) { Map map = (Map) Maps.safeGet(rowMap(), obj); if (map == null) { return null; } return (V) Maps.safeGet(map, obj2); } @Override // com.google.common.collect.Table public boolean isEmpty() { return size() == 0; } @Override // com.google.common.collect.Table public void clear() { Iterators.clear(cellSet().iterator()); } @Override // com.google.common.collect.Table @CheckForNull public V remove(@CheckForNull Object obj, @CheckForNull Object obj2) { Map map = (Map) Maps.safeGet(rowMap(), obj); if (map == null) { return null; } return (V) Maps.safeRemove(map, obj2); } @Override // com.google.common.collect.Table @CheckForNull public V put(@ParametricNullness R r, @ParametricNullness C c, @ParametricNullness V v) { return row(r).put(c, v); } @Override // com.google.common.collect.Table public void putAll(Table table) { for (Table.Cell cell : table.cellSet()) { put(cell.getRowKey(), cell.getColumnKey(), cell.getValue()); } } @Override // com.google.common.collect.Table public Set> cellSet() { Set> set = this.cellSet; if (set != null) { return set; } Set> createCellSet = createCellSet(); this.cellSet = createCellSet; return createCellSet; } Set> createCellSet() { return new CellSet(); } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public class CellSet extends AbstractSet> { CellSet() { } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(@CheckForNull Object obj) { if (!(obj instanceof Table.Cell)) { return false; } Table.Cell cell = (Table.Cell) obj; Map map = (Map) Maps.safeGet(AbstractTable.this.rowMap(), cell.getRowKey()); return map != null && Collections2.safeContains(map.entrySet(), Maps.immutableEntry(cell.getColumnKey(), cell.getValue())); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(@CheckForNull Object obj) { if (!(obj instanceof Table.Cell)) { return false; } Table.Cell cell = (Table.Cell) obj; Map map = (Map) Maps.safeGet(AbstractTable.this.rowMap(), cell.getRowKey()); return map != null && Collections2.safeRemove(map.entrySet(), Maps.immutableEntry(cell.getColumnKey(), cell.getValue())); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public void clear() { AbstractTable.this.clear(); } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator> iterator() { return AbstractTable.this.cellIterator(); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public int size() { return AbstractTable.this.size(); } } @Override // com.google.common.collect.Table public Collection values() { Collection collection = this.values; if (collection != null) { return collection; } Collection createValues = createValues(); this.values = createValues; return createValues; } Collection createValues() { return new Values(); } Iterator valuesIterator() { return new TransformedIterator, V>(this, cellSet().iterator()) { // from class: com.google.common.collect.AbstractTable.1 /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.common.collect.TransformedIterator @ParametricNullness public V transform(Table.Cell cell) { return cell.getValue(); } }; } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes3.dex */ public class Values extends AbstractCollection { Values() { } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable public Iterator iterator() { return AbstractTable.this.valuesIterator(); } @Override // java.util.AbstractCollection, java.util.Collection public boolean contains(@CheckForNull Object obj) { return AbstractTable.this.containsValue(obj); } @Override // java.util.AbstractCollection, java.util.Collection public void clear() { AbstractTable.this.clear(); } @Override // java.util.AbstractCollection, java.util.Collection public int size() { return AbstractTable.this.size(); } } @Override // com.google.common.collect.Table public boolean equals(@CheckForNull Object obj) { return Tables.equalsImpl(this, obj); } @Override // com.google.common.collect.Table public int hashCode() { return cellSet().hashCode(); } public String toString() { return rowMap().toString(); } }