67
67
import com .google .firebase .firestore .remote .WatchChange .WatchTargetChange ;
68
68
import com .google .firebase .firestore .remote .WatchChange .WatchTargetChangeType ;
69
69
import com .google .firebase .firestore .util .Assert ;
70
- import com .google .firestore .v1beta1 .BatchGetDocumentsResponse ;
71
- import com .google .firestore .v1beta1 .BatchGetDocumentsResponse .ResultCase ;
72
- import com .google .firestore .v1beta1 .Cursor ;
73
- import com .google .firestore .v1beta1 .DocumentChange ;
74
- import com .google .firestore .v1beta1 .DocumentDelete ;
75
- import com .google .firestore .v1beta1 .DocumentMask ;
76
- import com .google .firestore .v1beta1 .DocumentRemove ;
77
- import com .google .firestore .v1beta1 .DocumentTransform ;
78
- import com .google .firestore .v1beta1 .ListenResponse ;
79
- import com .google .firestore .v1beta1 .ListenResponse .ResponseTypeCase ;
80
- import com .google .firestore .v1beta1 .MapValue ;
81
- import com .google .firestore .v1beta1 .StructuredQuery ;
82
- import com .google .firestore .v1beta1 .StructuredQuery .CollectionSelector ;
83
- import com .google .firestore .v1beta1 .StructuredQuery .CompositeFilter ;
84
- import com .google .firestore .v1beta1 .StructuredQuery .FieldFilter ;
85
- import com .google .firestore .v1beta1 .StructuredQuery .FieldReference ;
86
- import com .google .firestore .v1beta1 .StructuredQuery .Filter .FilterTypeCase ;
87
- import com .google .firestore .v1beta1 .StructuredQuery .Order ;
88
- import com .google .firestore .v1beta1 .StructuredQuery .UnaryFilter ;
89
- import com .google .firestore .v1beta1 .Target ;
90
- import com .google .firestore .v1beta1 .Target .DocumentsTarget ;
91
- import com .google .firestore .v1beta1 .Target .QueryTarget ;
92
- import com .google .firestore .v1beta1 .Value ;
70
+ import com .google .firestore .v1 .BatchGetDocumentsResponse ;
71
+ import com .google .firestore .v1 .BatchGetDocumentsResponse .ResultCase ;
72
+ import com .google .firestore .v1 .Cursor ;
73
+ import com .google .firestore .v1 .DocumentChange ;
74
+ import com .google .firestore .v1 .DocumentDelete ;
75
+ import com .google .firestore .v1 .DocumentMask ;
76
+ import com .google .firestore .v1 .DocumentRemove ;
77
+ import com .google .firestore .v1 .DocumentTransform ;
78
+ import com .google .firestore .v1 .ListenResponse ;
79
+ import com .google .firestore .v1 .ListenResponse .ResponseTypeCase ;
80
+ import com .google .firestore .v1 .MapValue ;
81
+ import com .google .firestore .v1 .StructuredQuery ;
82
+ import com .google .firestore .v1 .StructuredQuery .CollectionSelector ;
83
+ import com .google .firestore .v1 .StructuredQuery .CompositeFilter ;
84
+ import com .google .firestore .v1 .StructuredQuery .FieldFilter ;
85
+ import com .google .firestore .v1 .StructuredQuery .FieldReference ;
86
+ import com .google .firestore .v1 .StructuredQuery .Filter .FilterTypeCase ;
87
+ import com .google .firestore .v1 .StructuredQuery .Order ;
88
+ import com .google .firestore .v1 .StructuredQuery .UnaryFilter ;
89
+ import com .google .firestore .v1 .Target ;
90
+ import com .google .firestore .v1 .Target .DocumentsTarget ;
91
+ import com .google .firestore .v1 .Target .QueryTarget ;
92
+ import com .google .firestore .v1 .Value ;
93
93
import com .google .protobuf .ByteString ;
94
94
import com .google .protobuf .Int32Value ;
95
95
import com .google .type .LatLng ;
@@ -181,7 +181,7 @@ private ResourcePath decodeQueryPath(String name) {
181
181
ResourcePath resource = decodeResourceName (name );
182
182
if (resource .length () == 4 ) {
183
183
// In v1beta1 queries for collections at the root did not have a trailing "/documents". In v1
184
- // all resource paths contain "/documents". Preserve the ability to read the v1beta1 form for
184
+ // all resource paths contain "/documents". Preserve the ability to read the v1 form for
185
185
// compatibility with queries persisted in the local query cache.
186
186
return ResourcePath .EMPTY ;
187
187
} else {
@@ -249,9 +249,8 @@ public String databaseName() {
249
249
* @param value the model to convert
250
250
* @return The proto representation of the model
251
251
*/
252
- public com .google .firestore .v1beta1 .Value encodeValue (FieldValue value ) {
253
- com .google .firestore .v1beta1 .Value .Builder builder =
254
- com .google .firestore .v1beta1 .Value .newBuilder ();
252
+ public com .google .firestore .v1 .Value encodeValue (FieldValue value ) {
253
+ com .google .firestore .v1 .Value .Builder builder = com .google .firestore .v1 .Value .newBuilder ();
255
254
256
255
if (value instanceof NullValue ) {
257
256
builder .setNullValueValue (0 );
@@ -298,7 +297,7 @@ public com.google.firestore.v1beta1.Value encodeValue(FieldValue value) {
298
297
*
299
298
* @return The model equivalent of the proto data.
300
299
*/
301
- public FieldValue decodeValue (com .google .firestore .v1beta1 .Value proto ) {
300
+ public FieldValue decodeValue (com .google .firestore .v1 .Value proto ) {
302
301
switch (proto .getValueTypeCase ()) {
303
302
case NULL_VALUE :
304
303
return NullValue .nullValue ();
@@ -334,17 +333,17 @@ public FieldValue decodeValue(com.google.firestore.v1beta1.Value proto) {
334
333
}
335
334
}
336
335
337
- private com .google .firestore .v1beta1 .ArrayValue encodeArrayValue (ArrayValue value ) {
336
+ private com .google .firestore .v1 .ArrayValue encodeArrayValue (ArrayValue value ) {
338
337
List <FieldValue > internalValue = value .getInternalValue ();
339
- com .google .firestore .v1beta1 .ArrayValue .Builder arrayBuilder =
340
- com .google .firestore .v1beta1 .ArrayValue .newBuilder ();
338
+ com .google .firestore .v1 .ArrayValue .Builder arrayBuilder =
339
+ com .google .firestore .v1 .ArrayValue .newBuilder ();
341
340
for (FieldValue subValue : internalValue ) {
342
341
arrayBuilder .addValues (encodeValue (subValue ));
343
342
}
344
343
return arrayBuilder .build ();
345
344
}
346
345
347
- private ArrayValue decodeArrayValue (com .google .firestore .v1beta1 .ArrayValue protoArray ) {
346
+ private ArrayValue decodeArrayValue (com .google .firestore .v1 .ArrayValue protoArray ) {
348
347
int count = protoArray .getValuesCount ();
349
348
List <FieldValue > wrappedList = new ArrayList <>(count );
350
349
for (int i = 0 ; i < count ; i ++) {
@@ -368,9 +367,9 @@ private ObjectValue decodeMapValue(MapValue value) {
368
367
// PORTING NOTE: There's no encodeFields here because there's no way to write it that doesn't
369
368
// involve creating a temporary map.
370
369
371
- public ObjectValue decodeFields (Map <String , com .google .firestore .v1beta1 .Value > fields ) {
370
+ public ObjectValue decodeFields (Map <String , com .google .firestore .v1 .Value > fields ) {
372
371
ObjectValue result = ObjectValue .emptyObject ();
373
- for (Map .Entry <String , com .google .firestore .v1beta1 .Value > entry : fields .entrySet ()) {
372
+ for (Map .Entry <String , com .google .firestore .v1 .Value > entry : fields .entrySet ()) {
374
373
FieldPath path = FieldPath .fromSingleSegment (entry .getKey ());
375
374
FieldValue value = decodeValue (entry .getValue ());
376
375
result = result .set (path , value );
@@ -380,9 +379,9 @@ public ObjectValue decodeFields(Map<String, com.google.firestore.v1beta1.Value>
380
379
381
380
// Documents
382
381
383
- public com .google .firestore .v1beta1 .Document encodeDocument (DocumentKey key , ObjectValue value ) {
384
- com .google .firestore .v1beta1 .Document .Builder builder =
385
- com .google .firestore .v1beta1 .Document .newBuilder ();
382
+ public com .google .firestore .v1 .Document encodeDocument (DocumentKey key , ObjectValue value ) {
383
+ com .google .firestore .v1 .Document .Builder builder =
384
+ com .google .firestore .v1 .Document .newBuilder ();
386
385
builder .setName (encodeKey (key ));
387
386
for (Map .Entry <String , FieldValue > entry : value .getInternalValue ()) {
388
387
builder .putFields (entry .getKey (), encodeValue (entry .getValue ()));
@@ -427,9 +426,8 @@ private NoDocument decodeMissingDocument(BatchGetDocumentsResponse response) {
427
426
// Mutations
428
427
429
428
/** Converts a Mutation model to a Write proto */
430
- public com .google .firestore .v1beta1 .Write encodeMutation (Mutation mutation ) {
431
- com .google .firestore .v1beta1 .Write .Builder builder =
432
- com .google .firestore .v1beta1 .Write .newBuilder ();
429
+ public com .google .firestore .v1 .Write encodeMutation (Mutation mutation ) {
430
+ com .google .firestore .v1 .Write .Builder builder = com .google .firestore .v1 .Write .newBuilder ();
433
431
if (mutation instanceof SetMutation ) {
434
432
builder .setUpdate (encodeDocument (mutation .getKey (), ((SetMutation ) mutation ).getValue ()));
435
433
} else if (mutation instanceof PatchMutation ) {
@@ -455,7 +453,7 @@ public com.google.firestore.v1beta1.Write encodeMutation(Mutation mutation) {
455
453
return builder .build ();
456
454
}
457
455
458
- public Mutation decodeMutation (com .google .firestore .v1beta1 .Write mutation ) {
456
+ public Mutation decodeMutation (com .google .firestore .v1 .Write mutation ) {
459
457
Precondition precondition =
460
458
mutation .hasCurrentDocument ()
461
459
? decodePrecondition (mutation .getCurrentDocument ())
@@ -496,10 +494,10 @@ public Mutation decodeMutation(com.google.firestore.v1beta1.Write mutation) {
496
494
}
497
495
}
498
496
499
- private com .google .firestore .v1beta1 .Precondition encodePrecondition (Precondition precondition ) {
497
+ private com .google .firestore .v1 .Precondition encodePrecondition (Precondition precondition ) {
500
498
hardAssert (!precondition .isNone (), "Can't serialize an empty precondition" );
501
- com .google .firestore .v1beta1 .Precondition .Builder builder =
502
- com .google .firestore .v1beta1 .Precondition .newBuilder ();
499
+ com .google .firestore .v1 .Precondition .Builder builder =
500
+ com .google .firestore .v1 .Precondition .newBuilder ();
503
501
if (precondition .getUpdateTime () != null ) {
504
502
return builder .setUpdateTime (encodeVersion (precondition .getUpdateTime ())).build ();
505
503
} else if (precondition .getExists () != null ) {
@@ -509,7 +507,7 @@ private com.google.firestore.v1beta1.Precondition encodePrecondition(Preconditio
509
507
}
510
508
}
511
509
512
- private Precondition decodePrecondition (com .google .firestore .v1beta1 .Precondition precondition ) {
510
+ private Precondition decodePrecondition (com .google .firestore .v1 .Precondition precondition ) {
513
511
switch (precondition .getConditionTypeCase ()) {
514
512
case UPDATE_TIME :
515
513
return Precondition .updateTime (decodeVersion (precondition .getUpdateTime ()));
@@ -563,10 +561,10 @@ private DocumentTransform.FieldTransform encodeFieldTransform(FieldTransform fie
563
561
}
564
562
}
565
563
566
- private com .google .firestore .v1beta1 .ArrayValue encodeArrayTransformElements (
564
+ private com .google .firestore .v1 .ArrayValue encodeArrayTransformElements (
567
565
List <FieldValue > elements ) {
568
- com .google .firestore .v1beta1 .ArrayValue .Builder arrayBuilder =
569
- com .google .firestore .v1beta1 .ArrayValue .newBuilder ();
566
+ com .google .firestore .v1 .ArrayValue .Builder arrayBuilder =
567
+ com .google .firestore .v1 .ArrayValue .newBuilder ();
570
568
for (FieldValue subValue : elements ) {
571
569
arrayBuilder .addValues (encodeValue (subValue ));
572
570
}
@@ -600,7 +598,7 @@ private FieldTransform decodeFieldTransform(DocumentTransform.FieldTransform fie
600
598
}
601
599
602
600
private List <FieldValue > decodeArrayTransformElements (
603
- com .google .firestore .v1beta1 .ArrayValue elementsProto ) {
601
+ com .google .firestore .v1 .ArrayValue elementsProto ) {
604
602
int count = elementsProto .getValuesCount ();
605
603
List <FieldValue > result = new ArrayList <>(count );
606
604
for (int i = 0 ; i < count ; i ++) {
@@ -610,7 +608,7 @@ private List<FieldValue> decodeArrayTransformElements(
610
608
}
611
609
612
610
public MutationResult decodeMutationResult (
613
- com .google .firestore .v1beta1 .WriteResult proto , SnapshotVersion commitVersion ) {
611
+ com .google .firestore .v1 .WriteResult proto , SnapshotVersion commitVersion ) {
614
612
// NOTE: Deletes don't have an updateTime but the commit timestamp from the containing
615
613
// CommitResponse or WriteResponse indicates essentially that the delete happened no later than
616
614
// that. For our purposes we don't care exactly when the delete happened so long as we can tell
@@ -977,7 +975,7 @@ public WatchChange decodeWatchChange(ListenResponse protoChange) {
977
975
978
976
switch (protoChange .getResponseTypeCase ()) {
979
977
case TARGET_CHANGE :
980
- com .google .firestore .v1beta1 .TargetChange targetChange = protoChange .getTargetChange ();
978
+ com .google .firestore .v1 .TargetChange targetChange = protoChange .getTargetChange ();
981
979
WatchTargetChangeType changeType ;
982
980
Status cause = null ;
983
981
switch (targetChange .getTargetChangeType ()) {
@@ -1038,7 +1036,7 @@ public WatchChange decodeWatchChange(ListenResponse protoChange) {
1038
1036
watchChange = new WatchChange .DocumentChange (Collections .emptyList (), removed , key , null );
1039
1037
break ;
1040
1038
case FILTER :
1041
- com .google .firestore .v1beta1 .ExistenceFilter protoFilter = protoChange .getFilter ();
1039
+ com .google .firestore .v1 .ExistenceFilter protoFilter = protoChange .getFilter ();
1042
1040
// TODO: implement existence filter parsing (see b/33076578)
1043
1041
ExistenceFilter filter = new ExistenceFilter (protoFilter .getCount ());
1044
1042
int targetId = protoFilter .getTargetId ();
0 commit comments