125 lines
5.0 KiB
Java
125 lines
5.0 KiB
Java
package com.google.firebase.firestore.remote;
|
|
|
|
import com.google.firebase.database.collection.ImmutableSortedSet;
|
|
import com.google.firebase.firestore.core.DocumentViewChange;
|
|
import com.google.firebase.firestore.model.DocumentKey;
|
|
import com.google.firebase.firestore.util.Assert;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import o.QwV;
|
|
|
|
/* loaded from: classes2.dex */
|
|
final class TargetState {
|
|
private int outstandingResponses = 0;
|
|
private final Map<DocumentKey, DocumentViewChange.Type> documentChanges = new HashMap();
|
|
private boolean hasChanges = true;
|
|
private QwV resumeToken = QwV.a;
|
|
private boolean current = false;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final TargetChange toTargetChange() {
|
|
ImmutableSortedSet<DocumentKey> emptyKeySet = DocumentKey.emptyKeySet();
|
|
ImmutableSortedSet<DocumentKey> emptyKeySet2 = DocumentKey.emptyKeySet();
|
|
ImmutableSortedSet<DocumentKey> emptyKeySet3 = DocumentKey.emptyKeySet();
|
|
ImmutableSortedSet<DocumentKey> immutableSortedSet = emptyKeySet;
|
|
ImmutableSortedSet<DocumentKey> immutableSortedSet2 = emptyKeySet2;
|
|
ImmutableSortedSet<DocumentKey> immutableSortedSet3 = emptyKeySet3;
|
|
for (Map.Entry<DocumentKey, DocumentViewChange.Type> entry : this.documentChanges.entrySet()) {
|
|
DocumentKey key = entry.getKey();
|
|
DocumentViewChange.Type value = entry.getValue();
|
|
int i = AnonymousClass1.$SwitchMap$com$google$firebase$firestore$core$DocumentViewChange$Type[value.ordinal()];
|
|
if (i == 1) {
|
|
immutableSortedSet = immutableSortedSet.insert(key);
|
|
} else if (i == 2) {
|
|
immutableSortedSet2 = immutableSortedSet2.insert(key);
|
|
} else if (i == 3) {
|
|
immutableSortedSet3 = immutableSortedSet3.insert(key);
|
|
} else {
|
|
throw Assert.fail("Encountered invalid change type: %s", value);
|
|
}
|
|
}
|
|
return new TargetChange(this.resumeToken, this.current, immutableSortedSet, immutableSortedSet2, immutableSortedSet3);
|
|
}
|
|
|
|
/* renamed from: com.google.firebase.firestore.remote.TargetState$1, reason: invalid class name */
|
|
/* loaded from: classes2.dex */
|
|
static /* synthetic */ class AnonymousClass1 {
|
|
static final int[] $SwitchMap$com$google$firebase$firestore$core$DocumentViewChange$Type;
|
|
|
|
static {
|
|
int[] iArr = new int[DocumentViewChange.Type.values().length];
|
|
$SwitchMap$com$google$firebase$firestore$core$DocumentViewChange$Type = iArr;
|
|
try {
|
|
iArr[DocumentViewChange.Type.ADDED.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$google$firebase$firestore$core$DocumentViewChange$Type[DocumentViewChange.Type.MODIFIED.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$google$firebase$firestore$core$DocumentViewChange$Type[DocumentViewChange.Type.REMOVED.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void clearChanges() {
|
|
this.hasChanges = false;
|
|
this.documentChanges.clear();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void addDocumentChange(DocumentKey documentKey, DocumentViewChange.Type type) {
|
|
this.hasChanges = true;
|
|
this.documentChanges.put(documentKey, type);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void removeDocumentChange(DocumentKey documentKey) {
|
|
this.hasChanges = true;
|
|
this.documentChanges.remove(documentKey);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void updateResumeToken(QwV qwV) {
|
|
if (qwV.g() == 0) {
|
|
return;
|
|
}
|
|
this.hasChanges = true;
|
|
this.resumeToken = qwV;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void recordTargetResponse() {
|
|
this.outstandingResponses--;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void recordPendingTargetRequest() {
|
|
this.outstandingResponses++;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void markCurrent() {
|
|
this.hasChanges = true;
|
|
this.current = true;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final boolean isPending() {
|
|
return this.outstandingResponses != 0;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final boolean isCurrent() {
|
|
return this.current;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final boolean hasChanges() {
|
|
return this.hasChanges;
|
|
}
|
|
}
|