268 lines
9.3 KiB
Java
268 lines
9.3 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.base.MoreObjects;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.collect.ImmutableList;
|
|
import com.google.common.collect.Table;
|
|
import com.google.common.collect.Tables;
|
|
import java.io.Serializable;
|
|
import java.util.Comparator;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class ImmutableTable<R, C, V> extends AbstractTable<R, C, V> implements Serializable {
|
|
|
|
public static final class Builder<R, C, V> {
|
|
private final List<Table.Cell<R, C, V>> a = Lists.a();
|
|
private Comparator<? super R> b;
|
|
private Comparator<? super C> c;
|
|
|
|
public Builder<R, C, V> a(R r, C c, V v) {
|
|
this.a.add(ImmutableTable.cellOf(r, c, v));
|
|
return this;
|
|
}
|
|
|
|
public Builder<R, C, V> a(Table.Cell<? extends R, ? extends C, ? extends V> cell) {
|
|
if (cell instanceof Tables.ImmutableCell) {
|
|
Preconditions.a(cell.b());
|
|
Preconditions.a(cell.a());
|
|
Preconditions.a(cell.getValue());
|
|
this.a.add(cell);
|
|
} else {
|
|
a(cell.b(), cell.a(), cell.getValue());
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public ImmutableTable<R, C, V> a() {
|
|
int size = this.a.size();
|
|
if (size == 0) {
|
|
return ImmutableTable.of();
|
|
}
|
|
if (size != 1) {
|
|
return RegularImmutableTable.a((List) this.a, (Comparator) this.b, (Comparator) this.c);
|
|
}
|
|
return new SingletonImmutableTable((Table.Cell) Iterables.c(this.a));
|
|
}
|
|
}
|
|
|
|
static final class SerializedForm implements Serializable {
|
|
private final Object[] a;
|
|
private final Object[] b;
|
|
private final Object[] c;
|
|
private final int[] d;
|
|
private final int[] e;
|
|
|
|
private SerializedForm(Object[] objArr, Object[] objArr2, Object[] objArr3, int[] iArr, int[] iArr2) {
|
|
this.a = objArr;
|
|
this.b = objArr2;
|
|
this.c = objArr3;
|
|
this.d = iArr;
|
|
this.e = iArr2;
|
|
}
|
|
|
|
static SerializedForm a(ImmutableTable<?, ?, ?> immutableTable, int[] iArr, int[] iArr2) {
|
|
return new SerializedForm(immutableTable.rowKeySet().toArray(), immutableTable.columnKeySet().toArray(), immutableTable.values().toArray(), iArr, iArr2);
|
|
}
|
|
|
|
Object readResolve() {
|
|
Object[] objArr = this.c;
|
|
if (objArr.length == 0) {
|
|
return ImmutableTable.of();
|
|
}
|
|
int i = 0;
|
|
if (objArr.length == 1) {
|
|
return ImmutableTable.of(this.a[0], this.b[0], objArr[0]);
|
|
}
|
|
ImmutableList.Builder builder = new ImmutableList.Builder(objArr.length);
|
|
while (true) {
|
|
Object[] objArr2 = this.c;
|
|
if (i >= objArr2.length) {
|
|
return RegularImmutableTable.a(builder.a(), ImmutableSet.copyOf(this.a), ImmutableSet.copyOf(this.b));
|
|
}
|
|
builder.a((ImmutableList.Builder) ImmutableTable.cellOf(this.a[this.d[i]], this.b[this.e[i]], objArr2[i]));
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
ImmutableTable() {
|
|
}
|
|
|
|
public static <R, C, V> Builder<R, C, V> builder() {
|
|
return new Builder<>();
|
|
}
|
|
|
|
static <R, C, V> Table.Cell<R, C, V> cellOf(R r, C c, V v) {
|
|
Preconditions.a(r);
|
|
Preconditions.a(c);
|
|
Preconditions.a(v);
|
|
return Tables.a(r, c, v);
|
|
}
|
|
|
|
public static <R, C, V> ImmutableTable<R, C, V> copyOf(Table<? extends R, ? extends C, ? extends V> table) {
|
|
return table instanceof ImmutableTable ? (ImmutableTable) table : copyOf(table.cellSet());
|
|
}
|
|
|
|
public static <R, C, V> ImmutableTable<R, C, V> of() {
|
|
return (ImmutableTable<R, C, V>) SparseImmutableTable.e;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
@Deprecated
|
|
public final void clear() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* renamed from: column, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Map mo11column(Object obj) {
|
|
return column((ImmutableTable<R, C, V>) obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table
|
|
public abstract ImmutableMap<C, Map<R, V>> columnMap();
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public boolean contains(Object obj, Object obj2) {
|
|
return get(obj, obj2) != null;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public /* bridge */ /* synthetic */ boolean containsColumn(Object obj) {
|
|
return super.containsColumn(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public /* bridge */ /* synthetic */ boolean containsRow(Object obj) {
|
|
return super.containsRow(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public boolean containsValue(Object obj) {
|
|
return values().contains(obj);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public abstract ImmutableSet<Table.Cell<R, C, V>> createCellSet();
|
|
|
|
abstract SerializedForm createSerializedForm();
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public abstract ImmutableCollection<V> createValues();
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public /* bridge */ /* synthetic */ boolean equals(Object obj) {
|
|
return super.equals(obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public /* bridge */ /* synthetic */ Object get(Object obj, Object obj2) {
|
|
return super.get(obj, obj2);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public /* bridge */ /* synthetic */ int hashCode() {
|
|
return super.hashCode();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public /* bridge */ /* synthetic */ boolean isEmpty() {
|
|
return super.isEmpty();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
@Deprecated
|
|
public final V put(R r, C c, V v) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
@Deprecated
|
|
public final void putAll(Table<? extends R, ? extends C, ? extends V> table) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
@Deprecated
|
|
public final V remove(Object obj, Object obj2) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* renamed from: row, reason: collision with other method in class */
|
|
public /* bridge */ /* synthetic */ Map m12row(Object obj) {
|
|
return row((ImmutableTable<R, C, V>) obj);
|
|
}
|
|
|
|
@Override // com.google.common.collect.Table
|
|
public abstract ImmutableMap<R, Map<C, V>> rowMap();
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public /* bridge */ /* synthetic */ String toString() {
|
|
return super.toString();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
final Iterator<V> valuesIterator() {
|
|
throw new AssertionError("should never be called");
|
|
}
|
|
|
|
final Object writeReplace() {
|
|
return createSerializedForm();
|
|
}
|
|
|
|
public static <R, C, V> ImmutableTable<R, C, V> of(R r, C c, V v) {
|
|
return new SingletonImmutableTable(r, c, v);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public final UnmodifiableIterator<Table.Cell<R, C, V>> cellIterator() {
|
|
throw new AssertionError("should never be called");
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public ImmutableSet<Table.Cell<R, C, V>> cellSet() {
|
|
return (ImmutableSet) super.cellSet();
|
|
}
|
|
|
|
public ImmutableMap<R, V> column(C c) {
|
|
Preconditions.a(c);
|
|
return (ImmutableMap) MoreObjects.a((ImmutableMap) columnMap().get(c), ImmutableMap.of());
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public ImmutableSet<C> columnKeySet() {
|
|
return columnMap().keySet();
|
|
}
|
|
|
|
public ImmutableMap<C, V> row(R r) {
|
|
Preconditions.a(r);
|
|
return (ImmutableMap) MoreObjects.a((ImmutableMap) rowMap().get(r), ImmutableMap.of());
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable, com.google.common.collect.Table
|
|
public ImmutableSet<R> rowKeySet() {
|
|
return rowMap().keySet();
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractTable
|
|
public ImmutableCollection<V> values() {
|
|
return (ImmutableCollection) super.values();
|
|
}
|
|
|
|
private static <R, C, V> ImmutableTable<R, C, V> copyOf(Iterable<? extends Table.Cell<? extends R, ? extends C, ? extends V>> iterable) {
|
|
Builder builder = builder();
|
|
Iterator<? extends Table.Cell<? extends R, ? extends C, ? extends V>> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
builder.a(it.next());
|
|
}
|
|
return builder.a();
|
|
}
|
|
}
|