@@ -124,8 +124,7 @@ public SnapshotVersion decodeVersion(com.google.protobuf.Timestamp proto) {
124
124
// Names and Keys
125
125
126
126
/**
127
- * Encodes the given document key as a fully qualified name. This includes the
128
- * databaseId from the
127
+ * Encodes the given document key as a fully qualified name. This includes the databaseId from the
129
128
* constructor and the key path.
130
129
*/
131
130
public String encodeKey (DocumentKey key ) {
@@ -170,10 +169,8 @@ private String encodeResourceName(DatabaseId databaseId, ResourcePath path) {
170
169
}
171
170
172
171
/**
173
- * Decodes a fully qualified resource name into a resource path and validates
174
- * that there is a
175
- * project and database encoded in the path. There are no guarantees that a
176
- * local path is also
172
+ * Decodes a fully qualified resource name into a resource path and validates that there is a
173
+ * project and database encoded in the path. There are no guarantees that a local path is also
177
174
* encoded in this resource name.
178
175
*/
179
176
private ResourcePath decodeResourceName (String encoded ) {
@@ -183,19 +180,15 @@ private ResourcePath decodeResourceName(String encoded) {
183
180
return resource ;
184
181
}
185
182
186
- /**
187
- * Creates the prefix for a fully qualified resource path, without a local path
188
- * on the end.
189
- */
183
+ /** Creates the prefix for a fully qualified resource path, without a local path on the end. */
190
184
private static ResourcePath encodedDatabaseId (DatabaseId databaseId ) {
191
185
return ResourcePath .fromSegments (
192
186
Arrays .asList (
193
187
"projects" , databaseId .getProjectId (), "databases" , databaseId .getDatabaseId ()));
194
188
}
195
189
196
190
/**
197
- * Decodes a fully qualified resource name into a resource path and validates
198
- * that there is a
191
+ * Decodes a fully qualified resource name into a resource path and validates that there is a
199
192
* project and database encoded in the path along with a local path.
200
193
*/
201
194
private static ResourcePath extractLocalPathFromResourceName (ResourcePath resourceName ) {
@@ -206,10 +199,7 @@ private static ResourcePath extractLocalPathFromResourceName(ResourcePath resour
206
199
return resourceName .popFirst (5 );
207
200
}
208
201
209
- /**
210
- * Validates that a path has a prefix that looks like a valid encoded
211
- * databaseId.
212
- */
202
+ /** Validates that a path has a prefix that looks like a valid encoded databaseId. */
213
203
private static boolean isValidResourceName (ResourcePath path ) {
214
204
// Resource names have at least 4 components (project ID, database ID)
215
205
// and commonly the (root) resource type, e.g. documents
@@ -231,7 +221,8 @@ public String databaseName() {
231
221
// Documents
232
222
233
223
public com .google .firestore .v1 .Document encodeDocument (DocumentKey key , ObjectValue value ) {
234
- com .google .firestore .v1 .Document .Builder builder = com .google .firestore .v1 .Document .newBuilder ();
224
+ com .google .firestore .v1 .Document .Builder builder =
225
+ com .google .firestore .v1 .Document .newBuilder ();
235
226
builder .setName (encodeKey (key ));
236
227
builder .putAllFields (value .getFieldsMap ());
237
228
return builder .build ();
@@ -300,9 +291,10 @@ public com.google.firestore.v1.Write encodeMutation(Mutation mutation) {
300
291
}
301
292
302
293
public Mutation decodeMutation (com .google .firestore .v1 .Write mutation ) {
303
- Precondition precondition = mutation .hasCurrentDocument ()
304
- ? decodePrecondition (mutation .getCurrentDocument ())
305
- : Precondition .NONE ;
294
+ Precondition precondition =
295
+ mutation .hasCurrentDocument ()
296
+ ? decodePrecondition (mutation .getCurrentDocument ())
297
+ : Precondition .NONE ;
306
298
307
299
List <FieldTransform > fieldTransforms = new ArrayList <>();
308
300
for (DocumentTransform .FieldTransform fieldTransform : mutation .getUpdateTransformsList ()) {
@@ -339,7 +331,8 @@ public Mutation decodeMutation(com.google.firestore.v1.Write mutation) {
339
331
340
332
private com .google .firestore .v1 .Precondition encodePrecondition (Precondition precondition ) {
341
333
hardAssert (!precondition .isNone (), "Can't serialize an empty precondition" );
342
- com .google .firestore .v1 .Precondition .Builder builder = com .google .firestore .v1 .Precondition .newBuilder ();
334
+ com .google .firestore .v1 .Precondition .Builder builder =
335
+ com .google .firestore .v1 .Precondition .newBuilder ();
343
336
if (precondition .getUpdateTime () != null ) {
344
337
return builder .setUpdateTime (encodeVersion (precondition .getUpdateTime ())).build ();
345
338
} else if (precondition .getExists () != null ) {
@@ -399,7 +392,8 @@ private DocumentTransform.FieldTransform encodeFieldTransform(FieldTransform fie
399
392
.setRemoveAllFromArray (ArrayValue .newBuilder ().addAllValues (remove .getElements ()))
400
393
.build ();
401
394
} else if (transform instanceof NumericIncrementTransformOperation ) {
402
- NumericIncrementTransformOperation incrementOperation = (NumericIncrementTransformOperation ) transform ;
395
+ NumericIncrementTransformOperation incrementOperation =
396
+ (NumericIncrementTransformOperation ) transform ;
403
397
return DocumentTransform .FieldTransform .newBuilder ()
404
398
.setFieldPath (fieldTransform .getFieldPath ().canonicalString ())
405
399
.setIncrement (incrementOperation .getOperand ())
@@ -413,7 +407,8 @@ private FieldTransform decodeFieldTransform(DocumentTransform.FieldTransform fie
413
407
switch (fieldTransform .getTransformTypeCase ()) {
414
408
case SET_TO_SERVER_VALUE :
415
409
hardAssert (
416
- fieldTransform .getSetToServerValue () == DocumentTransform .FieldTransform .ServerValue .REQUEST_TIME ,
410
+ fieldTransform .getSetToServerValue ()
411
+ == DocumentTransform .FieldTransform .ServerValue .REQUEST_TIME ,
417
412
"Unknown transform setToServerValue: %s" ,
418
413
fieldTransform .getSetToServerValue ());
419
414
return new FieldTransform (
@@ -464,8 +459,7 @@ public MutationResult decodeMutationResult(
464
459
465
460
@ Nullable
466
461
public Map <String , String > encodeListenRequestLabels (TargetData targetData ) {
467
- @ Nullable
468
- String value = encodeLabel (targetData .getPurpose ());
462
+ @ Nullable String value = encodeLabel (targetData .getPurpose ());
469
463
if (value == null ) {
470
464
return null ;
471
465
}
@@ -667,7 +661,8 @@ private List<Filter> decodeFilters(StructuredQuery.Filter proto) {
667
661
// containing F1,
668
662
// F2, ... to stay consistent with the older SDK versions.
669
663
if (result instanceof com .google .firebase .firestore .core .CompositeFilter ) {
670
- com .google .firebase .firestore .core .CompositeFilter compositeFilter = (com .google .firebase .firestore .core .CompositeFilter ) result ;
664
+ com .google .firebase .firestore .core .CompositeFilter compositeFilter =
665
+ (com .google .firebase .firestore .core .CompositeFilter ) result ;
671
666
if (compositeFilter .isFlatConjunction ()) {
672
667
return compositeFilter .getFilters ();
673
668
}
@@ -925,8 +920,9 @@ public WatchChange decodeWatchChange(ListenResponse protoChange) {
925
920
default :
926
921
throw new IllegalArgumentException ("Unknown target change type" );
927
922
}
928
- watchChange = new WatchTargetChange (
929
- changeType , targetChange .getTargetIdsList (), targetChange .getResumeToken (), cause );
923
+ watchChange =
924
+ new WatchTargetChange (
925
+ changeType , targetChange .getTargetIdsList (), targetChange .getResumeToken (), cause );
930
926
break ;
931
927
case DOCUMENT_CHANGE :
932
928
DocumentChange docChange = protoChange .getDocumentChange ();
@@ -947,7 +943,8 @@ public WatchChange decodeWatchChange(ListenResponse protoChange) {
947
943
// Note that version might be unset in which case we use SnapshotVersion.NONE
948
944
version = decodeVersion (docDelete .getReadTime ());
949
945
MutableDocument doc = MutableDocument .newNoDocument (key , version );
950
- watchChange = new WatchChange .DocumentChange (Collections .emptyList (), removed , doc .getKey (), doc );
946
+ watchChange =
947
+ new WatchChange .DocumentChange (Collections .emptyList (), removed , doc .getKey (), doc );
951
948
break ;
952
949
case DOCUMENT_REMOVE :
953
950
DocumentRemove docRemove = protoChange .getDocumentRemove ();
@@ -957,7 +954,8 @@ public WatchChange decodeWatchChange(ListenResponse protoChange) {
957
954
break ;
958
955
case FILTER :
959
956
com .google .firestore .v1 .ExistenceFilter protoFilter = protoChange .getFilter ();
960
- ExistenceFilter filter = new ExistenceFilter (protoFilter .getCount (), protoFilter .getUnchangedNames ());
957
+ ExistenceFilter filter =
958
+ new ExistenceFilter (protoFilter .getCount (), protoFilter .getUnchangedNames ());
961
959
int targetId = protoFilter .getTargetId ();
962
960
watchChange = new ExistenceFilterWatchChange (targetId , filter );
963
961
break ;
0 commit comments