Skip to content

Commit aa03b1b

Browse files
Remove value package, rename ProtoValues
1 parent 4864c6a commit aa03b1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+106
-136
lines changed

firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/TestUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import com.google.firebase.firestore.model.Document;
2727
import com.google.firebase.firestore.model.DocumentKey;
2828
import com.google.firebase.firestore.model.DocumentSet;
29-
import com.google.firebase.firestore.model.value.ObjectValue;
29+
import com.google.firebase.firestore.model.ObjectValue;
3030
import java.util.ArrayList;
3131
import java.util.List;
3232
import java.util.Map;

firebase-firestore/ktx/src/test/java/com/google/firebase/firestore/testutil/TestUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import com.google.firebase.firestore.model.DocumentSet;
2424
import com.google.firebase.firestore.model.ResourcePath;
2525
import com.google.firebase.firestore.model.SnapshotVersion;
26-
import com.google.firebase.firestore.model.value.ObjectValue;
26+
import com.google.firebase.firestore.model.ObjectValue;
2727
import com.google.firestore.v1.Value;
2828
import java.util.Comparator;
2929
import java.util.Map;

firebase-firestore/ktx/src/test/kotlin/com/google/firebase/firestore/ktx/FirestoreTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import com.google.firebase.firestore.FieldPath
2222
import com.google.firebase.firestore.FirebaseFirestore
2323
import com.google.firebase.firestore.FirebaseFirestoreSettings
2424
import com.google.firebase.firestore.TestUtil
25-
import com.google.firebase.firestore.model.value.ObjectValue
25+
import com.google.firebase.firestore.model.ObjectValue
2626
import com.google.firebase.firestore.testutil.TestUtil.wrap
2727
import com.google.firebase.ktx.Firebase
2828
import com.google.firebase.ktx.app

firebase-firestore/src/main/java/com/google/firebase/firestore/Query.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
import com.google.firebase.firestore.model.Document;
4040
import com.google.firebase.firestore.model.DocumentKey;
4141
import com.google.firebase.firestore.model.ResourcePath;
42-
import com.google.firebase.firestore.model.value.ProtoValues;
43-
import com.google.firebase.firestore.model.value.ServerTimestamps;
42+
import com.google.firebase.firestore.model.Values;
43+
import com.google.firebase.firestore.model.ServerTimestamps;
4444
import com.google.firebase.firestore.util.Executors;
4545
import com.google.firebase.firestore.util.Util;
4646
import com.google.firestore.v1.ArrayValue;
@@ -392,10 +392,10 @@ private Value parseDocumentIdValue(Object documentIdValue) {
392392
+ path.length()
393393
+ ").");
394394
}
395-
return ProtoValues.refValue(this.getFirestore().getDatabaseId(), DocumentKey.fromPath(path));
395+
return Values.refValue(this.getFirestore().getDatabaseId(), DocumentKey.fromPath(path));
396396
} else if (documentIdValue instanceof DocumentReference) {
397397
DocumentReference ref = (DocumentReference) documentIdValue;
398-
return ProtoValues.refValue(this.getFirestore().getDatabaseId(), ref.getKey());
398+
return Values.refValue(this.getFirestore().getDatabaseId(), ref.getKey());
399399
} else {
400400
throw new IllegalArgumentException(
401401
"Invalid query. When querying with FieldPath.documentId() you must provide a valid "
@@ -748,7 +748,7 @@ private Bound boundFromDocumentSnapshot(
748748
// orders), multiple documents could match the position, yielding duplicate results.
749749
for (OrderBy orderBy : query.getOrderBy()) {
750750
if (orderBy.getField().equals(com.google.firebase.firestore.model.FieldPath.KEY_PATH)) {
751-
components.add(ProtoValues.refValue(firestore.getDatabaseId(), document.getKey()));
751+
components.add(Values.refValue(firestore.getDatabaseId(), document.getKey()));
752752
} else {
753753
Value value = document.getField(orderBy.getField());
754754
if (ServerTimestamps.isServerTimestamp(value)) {
@@ -818,7 +818,7 @@ private Bound boundFromFields(String methodName, Object[] values, boolean before
818818
+ "' is not because it contains an odd number of segments.");
819819
}
820820
DocumentKey key = DocumentKey.fromPath(path);
821-
components.add(ProtoValues.refValue(firestore.getDatabaseId(), key));
821+
components.add(Values.refValue(firestore.getDatabaseId(), key));
822822
} else {
823823
Value wrapped = firestore.getUserDataReader().parseQueryValue(rawValue);
824824
components.add(wrapped);

firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import com.google.firebase.firestore.model.mutation.FieldMask;
3636
import com.google.firebase.firestore.model.mutation.NumericIncrementTransformOperation;
3737
import com.google.firebase.firestore.model.mutation.ServerTimestampOperation;
38-
import com.google.firebase.firestore.model.value.ObjectValue;
38+
import com.google.firebase.firestore.model.ObjectValue;
3939
import com.google.firebase.firestore.util.Assert;
4040
import com.google.firebase.firestore.util.CustomClassMapper;
4141
import com.google.firebase.firestore.util.Util;

firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataWriter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
package com.google.firebase.firestore;
1616

17-
import static com.google.firebase.firestore.model.value.ServerTimestamps.getLocalWriteTime;
18-
import static com.google.firebase.firestore.model.value.ServerTimestamps.getPreviousValue;
19-
import static com.google.firebase.firestore.model.value.ServerTimestamps.isServerTimestamp;
17+
import static com.google.firebase.firestore.model.ServerTimestamps.getLocalWriteTime;
18+
import static com.google.firebase.firestore.model.ServerTimestamps.getPreviousValue;
19+
import static com.google.firebase.firestore.model.ServerTimestamps.isServerTimestamp;
2020
import static com.google.firebase.firestore.util.Assert.fail;
2121

2222
import androidx.annotation.RestrictTo;

firebase-firestore/src/main/java/com/google/firebase/firestore/core/ArrayContainsAnyFilter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@
1818

1919
import com.google.firebase.firestore.model.Document;
2020
import com.google.firebase.firestore.model.FieldPath;
21-
import com.google.firebase.firestore.model.value.ProtoValues;
21+
import com.google.firebase.firestore.model.Values;
2222
import com.google.firestore.v1.Value;
2323

2424
/** A Filter that implements the array-contains-any operator. */
2525
public class ArrayContainsAnyFilter extends FieldFilter {
2626
ArrayContainsAnyFilter(FieldPath field, Value value) {
2727
super(field, Operator.ARRAY_CONTAINS_ANY, value);
28-
hardAssert(ProtoValues.isArray(value), "ArrayContainsAnyFilter expects an ArrayValue");
28+
hardAssert(Values.isArray(value), "ArrayContainsAnyFilter expects an ArrayValue");
2929
}
3030

3131
@Override
3232
public boolean matches(Document doc) {
3333
Value other = doc.getField(getField());
34-
if (!ProtoValues.isArray(other)) {
34+
if (!Values.isArray(other)) {
3535
return false;
3636
}
3737
for (Value val : other.getArrayValue().getValuesList()) {
38-
if (ProtoValues.contains(getValue().getArrayValue(), val)) {
38+
if (Values.contains(getValue().getArrayValue(), val)) {
3939
return true;
4040
}
4141
}

firebase-firestore/src/main/java/com/google/firebase/firestore/core/ArrayContainsFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import com.google.firebase.firestore.model.Document;
1818
import com.google.firebase.firestore.model.FieldPath;
19-
import com.google.firebase.firestore.model.value.ProtoValues;
19+
import com.google.firebase.firestore.model.Values;
2020
import com.google.firestore.v1.Value;
2121

2222
/** A Filter that implements the array-contains operator. */
@@ -28,6 +28,6 @@ public class ArrayContainsFilter extends FieldFilter {
2828
@Override
2929
public boolean matches(Document doc) {
3030
Value other = doc.getField(getField());
31-
return ProtoValues.isArray(other) && ProtoValues.contains(other.getArrayValue(), getValue());
31+
return Values.isArray(other) && Values.contains(other.getArrayValue(), getValue());
3232
}
3333
}

firebase-firestore/src/main/java/com/google/firebase/firestore/core/Bound.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.google.firebase.firestore.model.Document;
2121
import com.google.firebase.firestore.model.DocumentKey;
2222
import com.google.firebase.firestore.model.FieldPath;
23-
import com.google.firebase.firestore.model.value.ProtoValues;
23+
import com.google.firebase.firestore.model.Values;
2424
import com.google.firestore.v1.Value;
2525
import java.util.List;
2626

@@ -71,7 +71,7 @@ public String canonicalString() {
7171
builder.append(",");
7272
}
7373
first = false;
74-
builder.append(ProtoValues.canonicalId(indexComponent));
74+
builder.append(Values.canonicalId(indexComponent));
7575
}
7676
return builder.toString();
7777
}
@@ -85,7 +85,7 @@ public boolean sortsBeforeDocument(List<OrderBy> orderBy, Document document) {
8585
Value component = position.get(i);
8686
if (orderByComponent.field.equals(FieldPath.KEY_PATH)) {
8787
hardAssert(
88-
ProtoValues.isReferenceValue(component),
88+
Values.isReferenceValue(component),
8989
"Bound has a non-key value where the key path is being used %s",
9090
component);
9191
comparison =
@@ -94,7 +94,7 @@ public boolean sortsBeforeDocument(List<OrderBy> orderBy, Document document) {
9494
Value docValue = document.getField(orderByComponent.getField());
9595
hardAssert(
9696
docValue != null, "Field should exist since document matched the orderBy already.");
97-
comparison = ProtoValues.compare(component, docValue);
97+
comparison = Values.compare(component, docValue);
9898
}
9999

100100
if (orderByComponent.getDirection().equals(Direction.DESCENDING)) {

firebase-firestore/src/main/java/com/google/firebase/firestore/core/FieldFilter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import com.google.firebase.firestore.model.Document;
2020
import com.google.firebase.firestore.model.FieldPath;
21-
import com.google.firebase.firestore.model.value.ProtoValues;
21+
import com.google.firebase.firestore.model.Values;
2222
import com.google.firebase.firestore.util.Assert;
2323
import com.google.firestore.v1.Value;
2424
import java.util.Arrays;
@@ -70,13 +70,13 @@ public static FieldFilter create(FieldPath path, Operator operator, Value value)
7070
operator.toString() + "queries don't make sense on document keys");
7171
return new KeyFieldFilter(path, operator, value);
7272
}
73-
} else if (ProtoValues.isNullValue(value)) {
73+
} else if (Values.isNullValue(value)) {
7474
if (operator != Filter.Operator.EQUAL) {
7575
throw new IllegalArgumentException(
7676
"Invalid Query. Null supports only equality comparisons (via whereEqualTo()).");
7777
}
7878
return new FieldFilter(path, operator, value);
79-
} else if (ProtoValues.isNanValue(value)) {
79+
} else if (Values.isNanValue(value)) {
8080
if (operator != Filter.Operator.EQUAL) {
8181
throw new IllegalArgumentException(
8282
"Invalid Query. NaN supports only equality comparisons (via whereEqualTo()).");
@@ -98,8 +98,8 @@ public boolean matches(Document doc) {
9898
Value other = doc.getField(field);
9999
// Only compare types with matching backend order (such as double and int).
100100
return other != null
101-
&& ProtoValues.typeOrder(other) == ProtoValues.typeOrder(value)
102-
&& this.matchesComparison(ProtoValues.compare(other, value));
101+
&& Values.typeOrder(other) == Values.typeOrder(value)
102+
&& this.matchesComparison(Values.compare(other, value));
103103
}
104104

105105
protected boolean matchesComparison(int comp) {
@@ -134,7 +134,7 @@ public String getCanonicalId() {
134134
// such as the int 3 and the string "3". So we should add the types in here somehow, too.
135135
return getField().canonicalString()
136136
+ getOperator().toString()
137-
+ ProtoValues.canonicalId(getValue());
137+
+ Values.canonicalId(getValue());
138138
}
139139

140140
@Override

firebase-firestore/src/main/java/com/google/firebase/firestore/core/InFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818

1919
import com.google.firebase.firestore.model.Document;
2020
import com.google.firebase.firestore.model.FieldPath;
21-
import com.google.firebase.firestore.model.value.ProtoValues;
21+
import com.google.firebase.firestore.model.Values;
2222
import com.google.firestore.v1.Value;
2323

2424
/** A Filter that implements the IN operator. */
2525
public class InFilter extends FieldFilter {
2626
InFilter(FieldPath field, Value value) {
2727
super(field, Operator.IN, value);
28-
hardAssert(ProtoValues.isArray(value), "InFilter expects an ArrayValue");
28+
hardAssert(Values.isArray(value), "InFilter expects an ArrayValue");
2929
}
3030

3131
@Override
3232
public boolean matches(Document doc) {
3333
Value other = doc.getField(getField());
34-
return other != null && ProtoValues.contains(getValue().getArrayValue(), other);
34+
return other != null && Values.contains(getValue().getArrayValue(), other);
3535
}
3636
}

firebase-firestore/src/main/java/com/google/firebase/firestore/core/KeyFieldFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.google.firebase.firestore.model.Document;
2020
import com.google.firebase.firestore.model.DocumentKey;
2121
import com.google.firebase.firestore.model.FieldPath;
22-
import com.google.firebase.firestore.model.value.ProtoValues;
22+
import com.google.firebase.firestore.model.Values;
2323
import com.google.firestore.v1.Value;
2424

2525
/** Filter that matches on key fields (i.e. '__name__'). */
@@ -28,7 +28,7 @@ public class KeyFieldFilter extends FieldFilter {
2828

2929
KeyFieldFilter(FieldPath field, Operator operator, Value value) {
3030
super(field, operator, value);
31-
hardAssert(ProtoValues.isReferenceValue(value), "KeyFieldFilter expects a ReferenceValue");
31+
hardAssert(Values.isReferenceValue(value), "KeyFieldFilter expects a ReferenceValue");
3232
key = DocumentKey.fromName(getValue().getReferenceValue());
3333
}
3434

firebase-firestore/src/main/java/com/google/firebase/firestore/core/KeyFieldInFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.google.firebase.firestore.model.Document;
2020
import com.google.firebase.firestore.model.DocumentKey;
2121
import com.google.firebase.firestore.model.FieldPath;
22-
import com.google.firebase.firestore.model.value.ProtoValues;
22+
import com.google.firebase.firestore.model.Values;
2323
import com.google.firestore.v1.Value;
2424
import java.util.ArrayList;
2525
import java.util.List;
@@ -30,10 +30,10 @@ public class KeyFieldInFilter extends FieldFilter {
3030
KeyFieldInFilter(FieldPath field, Value value) {
3131
super(field, Operator.IN, value);
3232

33-
hardAssert(ProtoValues.isArray(value), "KeyFieldInFilter expects an ArrayValue");
33+
hardAssert(Values.isArray(value), "KeyFieldInFilter expects an ArrayValue");
3434
for (Value element : value.getArrayValue().getValuesList()) {
3535
hardAssert(
36-
ProtoValues.isReferenceValue(element),
36+
Values.isReferenceValue(element),
3737
"Comparing on key with IN, but an array value was not a ReferenceValue");
3838
keys.add(DocumentKey.fromName(element.getReferenceValue()));
3939
}

firebase-firestore/src/main/java/com/google/firebase/firestore/core/OrderBy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import com.google.firebase.firestore.model.Document;
1818
import com.google.firebase.firestore.model.FieldPath;
19-
import com.google.firebase.firestore.model.value.ProtoValues;
19+
import com.google.firebase.firestore.model.Values;
2020
import com.google.firebase.firestore.util.Assert;
2121
import com.google.firestore.v1.Value;
2222

@@ -66,7 +66,7 @@ int compare(Document d1, Document d2) {
6666
Value v2 = d2.getField(field);
6767
Assert.hardAssert(
6868
v1 != null && v2 != null, "Trying to compare documents on fields that don't exist.");
69-
return direction.getComparisonModifier() * ProtoValues.compare(v1, v2);
69+
return direction.getComparisonModifier() * Values.compare(v1, v2);
7070
}
7171
}
7272

firebase-firestore/src/main/java/com/google/firebase/firestore/core/UserData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import com.google.firebase.firestore.model.mutation.SetMutation;
2828
import com.google.firebase.firestore.model.mutation.TransformMutation;
2929
import com.google.firebase.firestore.model.mutation.TransformOperation;
30-
import com.google.firebase.firestore.model.value.ObjectValue;
30+
import com.google.firebase.firestore.model.ObjectValue;
3131
import com.google.firebase.firestore.util.Assert;
3232
import java.util.ArrayList;
3333
import java.util.HashSet;

firebase-firestore/src/main/java/com/google/firebase/firestore/local/IndexedQueryEngine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import com.google.firebase.firestore.model.FieldPath;
3232
import com.google.firebase.firestore.model.MaybeDocument;
3333
import com.google.firebase.firestore.model.SnapshotVersion;
34-
import com.google.firebase.firestore.model.value.ProtoValues;
34+
import com.google.firebase.firestore.model.Values;
3535
import com.google.firebase.firestore.util.Assert;
3636
import com.google.firestore.v1.Value;
3737
import java.util.Arrays;
@@ -166,7 +166,7 @@ private static double estimateFilterSelectivity(Filter filter) {
166166
hardAssert(filter instanceof FieldFilter, "Filter type expected to be FieldFilter");
167167
FieldFilter fieldFilter = (FieldFilter) filter;
168168
Value filterValue = fieldFilter.getValue();
169-
if (ProtoValues.isNullValue(filterValue) || ProtoValues.isNanValue(filterValue)) {
169+
if (Values.isNullValue(filterValue) || Values.isNanValue(filterValue)) {
170170
return HIGH_SELECTIVITY;
171171
} else {
172172
double operatorSelectivity =

firebase-firestore/src/main/java/com/google/firebase/firestore/local/LocalSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import com.google.firebase.firestore.model.UnknownDocument;
2828
import com.google.firebase.firestore.model.mutation.Mutation;
2929
import com.google.firebase.firestore.model.mutation.MutationBatch;
30-
import com.google.firebase.firestore.model.value.ObjectValue;
30+
import com.google.firebase.firestore.model.ObjectValue;
3131
import com.google.firebase.firestore.remote.RemoteSerializer;
3232
import com.google.protobuf.ByteString;
3333
import java.util.ArrayList;

firebase-firestore/src/main/java/com/google/firebase/firestore/local/LocalStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import com.google.firebase.firestore.model.mutation.MutationBatchResult;
3838
import com.google.firebase.firestore.model.mutation.PatchMutation;
3939
import com.google.firebase.firestore.model.mutation.Precondition;
40-
import com.google.firebase.firestore.model.value.ObjectValue;
40+
import com.google.firebase.firestore.model.ObjectValue;
4141
import com.google.firebase.firestore.remote.RemoteEvent;
4242
import com.google.firebase.firestore.remote.TargetChange;
4343
import com.google.firebase.firestore.util.Logger;

firebase-firestore/src/main/java/com/google/firebase/firestore/model/Document.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import androidx.annotation.NonNull;
1818
import androidx.annotation.Nullable;
19-
import com.google.firebase.firestore.model.value.ObjectValue;
19+
2020
import com.google.firestore.v1.Value;
2121
import java.util.Comparator;
2222

0 commit comments

Comments
 (0)