what-the-bank/sources/com/google/android/gms/common/data/EntityBuffer.java

106 lines
4.1 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.common.data;
import com.google.android.gms.common.internal.Preconditions;
import java.util.ArrayList;
/* loaded from: classes.dex */
public abstract class EntityBuffer<T> extends AbstractDataBuffer<T> {
private boolean zaa;
private ArrayList<Integer> zab;
protected EntityBuffer(DataHolder dataHolder) {
super(dataHolder);
this.zaa = false;
}
private final void zab() {
synchronized (this) {
if (!this.zaa) {
int count = ((DataHolder) Preconditions.checkNotNull(this.mDataHolder)).getCount();
ArrayList<Integer> arrayList = new ArrayList<>();
this.zab = arrayList;
if (count > 0) {
arrayList.add(0);
String primaryDataMarkerColumn = getPrimaryDataMarkerColumn();
String string = this.mDataHolder.getString(primaryDataMarkerColumn, 0, this.mDataHolder.getWindowIndex(0));
for (int i = 1; i < count; i++) {
int windowIndex = this.mDataHolder.getWindowIndex(i);
String string2 = this.mDataHolder.getString(primaryDataMarkerColumn, i, windowIndex);
if (string2 != null) {
if (!string2.equals(string)) {
this.zab.add(Integer.valueOf(i));
string = string2;
}
} else {
StringBuilder sb = new StringBuilder(String.valueOf(primaryDataMarkerColumn).length() + 78);
sb.append("Missing value for markerColumn: ");
sb.append(primaryDataMarkerColumn);
sb.append(", at row: ");
sb.append(i);
sb.append(", for window: ");
sb.append(windowIndex);
throw new NullPointerException(sb.toString());
}
}
}
this.zaa = true;
}
}
}
@Override // com.google.android.gms.common.data.AbstractDataBuffer, com.google.android.gms.common.data.DataBuffer
public final T get(int i) {
int intValue;
int intValue2;
zab();
int zaa = zaa(i);
int i2 = 0;
if (i >= 0 && i != this.zab.size()) {
if (i == this.zab.size() - 1) {
intValue = ((DataHolder) Preconditions.checkNotNull(this.mDataHolder)).getCount();
intValue2 = this.zab.get(i).intValue();
} else {
intValue = this.zab.get(i + 1).intValue();
intValue2 = this.zab.get(i).intValue();
}
int i3 = intValue - intValue2;
if (i3 == 1) {
int zaa2 = zaa(i);
int windowIndex = ((DataHolder) Preconditions.checkNotNull(this.mDataHolder)).getWindowIndex(zaa2);
String childDataMarkerColumn = getChildDataMarkerColumn();
if (childDataMarkerColumn == null || this.mDataHolder.getString(childDataMarkerColumn, zaa2, windowIndex) != null) {
i2 = 1;
}
} else {
i2 = i3;
}
}
return getEntry(zaa, i2);
}
protected String getChildDataMarkerColumn() {
return null;
}
@Override // com.google.android.gms.common.data.AbstractDataBuffer, com.google.android.gms.common.data.DataBuffer
public int getCount() {
zab();
return this.zab.size();
}
protected abstract T getEntry(int i, int i2);
protected abstract String getPrimaryDataMarkerColumn();
final int zaa(int i) {
if (i < 0 || i >= this.zab.size()) {
StringBuilder sb = new StringBuilder(53);
sb.append("Position ");
sb.append(i);
sb.append(" is out of bounds for this buffer");
throw new IllegalArgumentException(sb.toString());
}
return this.zab.get(i).intValue();
}
}