Skip to content

Commit 4aa3ceb

Browse files
committed
/gradlew :firebase-firestore:googleJavaFormat
1 parent 965144b commit 4aa3ceb

File tree

5 files changed

+28
-32
lines changed

5 files changed

+28
-32
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/CountTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
import static org.junit.Assert.assertEquals;
2121

2222
import androidx.test.ext.junit.runners.AndroidJUnit4;
23-
24-
import com.google.firebase.firestore.AggregateField;
25-
import com.google.firebase.firestore.AggregateQuerySnapshot;
2623
import com.google.firebase.firestore.testutil.IntegrationTestUtil;
27-
2824
import org.junit.After;
2925
import org.junit.Test;
3026
import org.junit.runner.RunWith;
@@ -49,5 +45,4 @@ public void count() {
4945
AggregateQuerySnapshot snapshot = waitFor(collection.count().get());
5046
assertEquals(Long.valueOf(3), snapshot.get(AggregateField.count()));
5147
}
52-
5348
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,12 @@ public static CountAggregateField count() {
2828

2929
public static final class CountAggregateField extends AggregateField {
3030

31-
@Nullable
32-
private Integer upTo;
31+
@Nullable private Integer upTo;
3332

34-
CountAggregateField() {
35-
}
33+
CountAggregateField() {}
3634

3735
CountAggregateField(@Nullable Integer upTo) {
3836
this.upTo = upTo;
3937
}
40-
4138
}
42-
4339
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.google.firebase.firestore;
1616

1717
import androidx.annotation.NonNull;
18-
1918
import com.google.android.gms.tasks.Task;
2019
import com.google.android.gms.tasks.TaskCompletionSource;
2120
import com.google.firebase.firestore.remote.Datastore;
@@ -27,7 +26,7 @@ public final class AggregateQuery {
2726

2827
AggregateQuery(@NonNull Query query, @NonNull AggregateField aggregateField) {
2928
this.query = query;
30-
if (! (aggregateField instanceof AggregateField.CountAggregateField)) {
29+
if (!(aggregateField instanceof AggregateField.CountAggregateField)) {
3130
throw new IllegalArgumentException("unsupported aggregateField: " + aggregateField);
3231
}
3332
}
@@ -44,16 +43,17 @@ public Task<AggregateQuerySnapshot> get() {
4443

4544
datastore
4645
.runCountQuery(query.query.toTarget())
47-
.continueWith(Executors.DIRECT_EXECUTOR, task -> {
48-
if (task.isSuccessful()) {
49-
tcs.setResult(new AggregateQuerySnapshot(task.getResult()));
50-
} else {
51-
tcs.setException(task.getException());
52-
}
53-
return null;
54-
});
46+
.continueWith(
47+
Executors.DIRECT_EXECUTOR,
48+
task -> {
49+
if (task.isSuccessful()) {
50+
tcs.setResult(new AggregateQuerySnapshot(task.getResult()));
51+
} else {
52+
tcs.setException(task.getException());
53+
}
54+
return null;
55+
});
5556

5657
return tcs.getTask();
5758
}
58-
5959
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ public class AggregateQuerySnapshot {
2929
public Long get(@NonNull AggregateField.CountAggregateField field) {
3030
return count;
3131
}
32-
3332
}

firebase-firestore/src/main/java/com/google/firebase/firestore/remote/Datastore.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@
4141
import com.google.firestore.v1.FirestoreGrpc;
4242
import com.google.firestore.v1.RunAggregationQueryRequest;
4343
import com.google.firestore.v1.RunAggregationQueryResponse;
44-
import com.google.firestore.v1.RunQueryRequest;
4544
import com.google.firestore.v1.StructuredAggregationQuery;
4645
import com.google.firestore.v1.Value;
47-
4846
import io.grpc.Status;
4947
import java.util.ArrayList;
5048
import java.util.Arrays;
@@ -225,12 +223,15 @@ public void onClose(Status status) {
225223
}
226224

227225
public Task<Long> runCountQuery(Target queryTarget) {
228-
com.google.firestore.v1.Target.QueryTarget encodedQueryTarget = serializer.encodeQueryTarget(queryTarget);
226+
com.google.firestore.v1.Target.QueryTarget encodedQueryTarget =
227+
serializer.encodeQueryTarget(queryTarget);
229228

230-
StructuredAggregationQuery.Builder structuredAggregationQuery = StructuredAggregationQuery.newBuilder();
229+
StructuredAggregationQuery.Builder structuredAggregationQuery =
230+
StructuredAggregationQuery.newBuilder();
231231
structuredAggregationQuery.setStructuredQuery(encodedQueryTarget.getStructuredQuery());
232232

233-
StructuredAggregationQuery.Aggregation.Builder aggregation = StructuredAggregationQuery.Aggregation.newBuilder();
233+
StructuredAggregationQuery.Aggregation.Builder aggregation =
234+
StructuredAggregationQuery.Aggregation.newBuilder();
234235
aggregation.setCount(StructuredAggregationQuery.Aggregation.Count.getDefaultInstance());
235236
aggregation.setAlias("zzyzx_agg_alias_count");
236237
structuredAggregationQuery.addAggregations(aggregation);
@@ -239,13 +240,14 @@ public Task<Long> runCountQuery(Target queryTarget) {
239240
request.setParent(encodedQueryTarget.getParent());
240241
request.setStructuredAggregationQuery(structuredAggregationQuery);
241242

242-
return channel.runRpc(FirestoreGrpc.getRunAggregationQueryMethod(), request.build())
243+
return channel
244+
.runRpc(FirestoreGrpc.getRunAggregationQueryMethod(), request.build())
243245
.continueWith(
244246
workerQueue.getExecutor(),
245247
task -> {
246248
if (!task.isSuccessful()) {
247249
if (task.getException() instanceof FirebaseFirestoreException
248-
&& ((FirebaseFirestoreException) task.getException()).getCode()
250+
&& ((FirebaseFirestoreException) task.getException()).getCode()
249251
== FirebaseFirestoreException.Code.UNAUTHENTICATED) {
250252
channel.invalidateToken();
251253
}
@@ -255,10 +257,14 @@ public Task<Long> runCountQuery(Target queryTarget) {
255257

256258
AggregationResult aggregationResult = response.getResult();
257259
Map<String, Value> aggregateFieldsByAlias = aggregationResult.getAggregateFieldsMap();
258-
hardAssert(aggregateFieldsByAlias.size() == 1, "aggregateFieldsByAlias.size()==" + aggregateFieldsByAlias.size());
260+
hardAssert(
261+
aggregateFieldsByAlias.size() == 1,
262+
"aggregateFieldsByAlias.size()==" + aggregateFieldsByAlias.size());
259263
Value countValue = aggregateFieldsByAlias.get("zzyzx_agg_alias_count");
260264
hardAssert(countValue != null, "countValue == null");
261-
hardAssert(countValue.getValueTypeCase() == Value.ValueTypeCase.INTEGER_VALUE, "countValue.getValueTypeCase() == " + countValue.getValueTypeCase());
265+
hardAssert(
266+
countValue.getValueTypeCase() == Value.ValueTypeCase.INTEGER_VALUE,
267+
"countValue.getValueTypeCase() == " + countValue.getValueTypeCase());
262268
return countValue.getIntegerValue();
263269
});
264270
}

0 commit comments

Comments
 (0)