Skip to content

Commit 12d4f29

Browse files
committed
Add annotations.
1 parent 478c46c commit 12d4f29

Some content is hidden

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

76 files changed

+516
-24
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
package com.google.cloud.firestore;
1818

1919
import com.google.api.core.ApiFuture;
20+
import com.google.api.core.BetaApi;
2021
import com.google.api.core.InternalExtensionOnly;
2122
import com.google.api.core.SettableApiFuture;
2223
import com.google.api.gax.rpc.ResponseObserver;
2324
import com.google.api.gax.rpc.ServerStreamingCallable;
2425
import com.google.api.gax.rpc.StatusCode;
2526
import com.google.api.gax.rpc.StreamController;
2627
import com.google.cloud.Timestamp;
27-
import com.google.cloud.firestore.pipeline.expressions.AggregatorTarget;
28+
import com.google.cloud.firestore.pipeline.expressions.AccumulatorTarget;
2829
import com.google.cloud.firestore.v1.FirestoreSettings;
2930
import com.google.common.collect.ImmutableMap;
3031
import com.google.firestore.v1.RunAggregationQueryRequest;
@@ -67,13 +68,14 @@ public Query getQuery() {
6768
}
6869

6970
@Nonnull
71+
@BetaApi
7072
public Pipeline pipeline() {
7173
return getQuery()
7274
.pipeline()
7375
.aggregate(
7476
this.aggregateFieldList.stream()
7577
.map(PipelineUtils::toPipelineAggregatorTarget)
76-
.toArray(AggregatorTarget[]::new));
78+
.toArray(AccumulatorTarget[]::new));
7779
}
7880

7981
/**

google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package com.google.cloud.firestore;
22

33
import com.google.api.core.ApiFuture;
4+
import com.google.api.core.BetaApi;
5+
import com.google.api.core.InternalExtensionOnly;
46
import com.google.api.core.SettableApiFuture;
57
import com.google.api.gax.rpc.ApiStreamObserver;
68
import com.google.api.gax.rpc.ResponseObserver;
79
import com.google.api.gax.rpc.StreamController;
810
import com.google.cloud.Timestamp;
911
import com.google.cloud.firestore.pipeline.PaginatingPipeline;
10-
import com.google.cloud.firestore.pipeline.expressions.AggregatorTarget;
12+
import com.google.cloud.firestore.pipeline.expressions.AccumulatorTarget;
1113
import com.google.cloud.firestore.pipeline.expressions.Expr;
1214
import com.google.cloud.firestore.pipeline.expressions.ExprWithAlias;
1315
import com.google.cloud.firestore.pipeline.expressions.Field;
@@ -81,6 +83,7 @@
8183
* <p>```java Pipeline pipeline = Pipeline.fromCollection("orders") .group(Field.of("customerId"))
8284
* .aggregate(count(Field.of("orderId")).asAlias("orderCount")); ```
8385
*/
86+
@BetaApi
8487
public final class Pipeline {
8588
private final ImmutableList<Stage> stages;
8689

@@ -110,8 +113,8 @@ private Map<String, Expr> projectablesToMap(Selectable... selectables) {
110113
if (proj instanceof Field) {
111114
Field fieldProj = (Field) proj;
112115
projMap.put(fieldProj.getPath().getEncodedPath(), fieldProj);
113-
} else if (proj instanceof AggregatorTarget) {
114-
AggregatorTarget aggregatorProj = (AggregatorTarget) proj;
116+
} else if (proj instanceof AccumulatorTarget) {
117+
AccumulatorTarget aggregatorProj = (AccumulatorTarget) proj;
115118
projMap.put(aggregatorProj.getFieldName(), aggregatorProj.getAccumulator());
116119
} else if (proj instanceof Fields) {
117120
Fields fieldsProj = (Fields) proj;
@@ -134,6 +137,7 @@ private Map<String, Expr> fieldNamesToMap(String... fields) {
134137
return projMap;
135138
}
136139

140+
@BetaApi
137141
public Pipeline addFields(Selectable... fields) {
138142
return new Pipeline(
139143
ImmutableList.<Stage>builder()
@@ -142,6 +146,7 @@ public Pipeline addFields(Selectable... fields) {
142146
.build());
143147
}
144148

149+
@BetaApi
145150
public Pipeline select(Selectable... projections) {
146151
return new Pipeline(
147152
ImmutableList.<Stage>builder()
@@ -150,6 +155,7 @@ public Pipeline select(Selectable... projections) {
150155
.build());
151156
}
152157

158+
@BetaApi
153159
public Pipeline select(String... fields) {
154160
return new Pipeline(
155161
ImmutableList.<Stage>builder()
@@ -158,31 +164,37 @@ public Pipeline select(String... fields) {
158164
.build());
159165
}
160166

167+
@BetaApi
161168
public Pipeline where(FilterCondition condition) {
162169
return new Pipeline(
163170
ImmutableList.<Stage>builder().addAll(stages).add(new Where(condition)).build());
164171
}
165172

173+
@BetaApi
166174
public Pipeline offset(int offset) {
167175
return new Pipeline(
168176
ImmutableList.<Stage>builder().addAll(stages).add(new Offset(offset)).build());
169177
}
170178

179+
@BetaApi
171180
public Pipeline limit(int limit) {
172181
return new Pipeline(
173182
ImmutableList.<Stage>builder().addAll(stages).add(new Limit(limit)).build());
174183
}
175184

176-
public Pipeline aggregate(AggregatorTarget... aggregators) {
185+
@BetaApi
186+
public Pipeline aggregate(AccumulatorTarget... aggregators) {
177187
return new Pipeline(
178188
ImmutableList.<Stage>builder().addAll(stages).add(new Aggregate(aggregators)).build());
179189
}
180190

191+
@BetaApi
181192
public Pipeline findNearest(
182193
String fieldName, double[] vector, FindNearest.FindNearestOptions options) {
183194
return findNearest(Field.of(fieldName), vector, options);
184195
}
185196

197+
@BetaApi
186198
public Pipeline findNearest(
187199
Field property, double[] vector, FindNearest.FindNearestOptions options) {
188200
// Implementation for findNearest (add the FindNearest stage if needed)
@@ -195,6 +207,7 @@ public Pipeline findNearest(
195207
.build());
196208
}
197209

210+
@BetaApi
198211
public Pipeline sort(List<Ordering> orders, Sort.Density density, Sort.Truncation truncation) {
199212
return new Pipeline(
200213
ImmutableList.<Stage>builder()
@@ -204,14 +217,17 @@ public Pipeline sort(List<Ordering> orders, Sort.Density density, Sort.Truncatio
204217
}
205218

206219
// Sugar
220+
@BetaApi
207221
public Pipeline sort(Ordering... orders) {
208222
return sort(Arrays.asList(orders), Sort.Density.UNSPECIFIED, Sort.Truncation.UNSPECIFIED);
209223
}
210224

225+
@BetaApi
211226
public PaginatingPipeline paginate(int pageSize, Ordering... orders) {
212227
return new PaginatingPipeline(this, pageSize, Arrays.asList(orders));
213228
}
214229

230+
@BetaApi
215231
public Pipeline genericStage(String name, Map<String, Object> params) {
216232
// Implementation for genericStage (add the GenericStage if needed)
217233
return new Pipeline(
@@ -225,6 +241,7 @@ public Pipeline genericStage(String name, Map<String, Object> params) {
225241
.build());
226242
}
227243

244+
@BetaApi
228245
public ApiFuture<List<PipelineResult>> execute(Firestore db) {
229246
if (db instanceof FirestoreImpl) {
230247
FirestoreImpl firestoreImpl = (FirestoreImpl) db;
@@ -269,6 +286,7 @@ public void onError(Throwable t) {
269286
}
270287
}
271288

289+
@BetaApi
272290
public void execute(Firestore db, ApiStreamObserver<PipelineResult> observer) {
273291
if (db instanceof FirestoreImpl) {
274292
FirestoreImpl firestoreImpl = (FirestoreImpl) db;
@@ -307,7 +325,7 @@ public void onError(Throwable t) {
307325
}
308326
}
309327

310-
public Value toProto() {
328+
private Value toProto() {
311329
return Value.newBuilder()
312330
.setPipelineValue(
313331
com.google.firestore.v1.Pipeline.newBuilder()
@@ -392,6 +410,7 @@ public void onComplete() {
392410
}
393411
}
394412

413+
@InternalExtensionOnly
395414
abstract class PipelineResultObserver implements ApiStreamObserver<PipelineResult> {
396415
private Timestamp executionTime; // Remove optional since Java doesn't have it
397416

google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.java

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

1717
package com.google.cloud.firestore;
1818

19+
import com.google.api.core.BetaApi;
1920
import com.google.api.core.InternalExtensionOnly;
2021
import com.google.cloud.Timestamp;
2122
import com.google.common.base.Preconditions;
@@ -43,6 +44,7 @@
4344
* that does so.
4445
*/
4546
@InternalExtensionOnly
47+
@BetaApi
4648
public final class PipelineResult {
4749

4850
private final FirestoreRpcContext<?> rpcContext;
@@ -73,6 +75,7 @@ public final class PipelineResult {
7375
* @return The id of the document.
7476
*/
7577
@Nonnull
78+
@BetaApi
7679
public String getId() {
7780
return docRef.getId();
7881
}
@@ -96,6 +99,7 @@ static PipelineResult fromDocument(
9699
* @return The read time of this snapshot.
97100
*/
98101
@Nullable
102+
@BetaApi
99103
public Timestamp getReadTime() {
100104
return readTime;
101105
}
@@ -108,6 +112,7 @@ public Timestamp getReadTime() {
108112
* exist.
109113
*/
110114
@Nullable
115+
@BetaApi
111116
public Timestamp getUpdateTime() {
112117
return updateTime;
113118
}
@@ -119,6 +124,7 @@ public Timestamp getUpdateTime() {
119124
* exist.
120125
*/
121126
@Nullable
127+
@BetaApi
122128
public Timestamp getCreateTime() {
123129
return createTime;
124130
}
@@ -129,6 +135,7 @@ public Timestamp getCreateTime() {
129135
*
130136
* @return whether the document existed in this snapshot.
131137
*/
138+
@BetaApi
132139
public boolean exists() {
133140
return fields != null;
134141
}
@@ -140,6 +147,7 @@ public boolean exists() {
140147
* @return The fields of the document as a Map or null if the document doesn't exist.
141148
*/
142149
@Nullable
150+
@BetaApi
143151
public Map<String, Object> getData() {
144152
if (fields == null) {
145153
return null;
@@ -161,6 +169,7 @@ public Map<String, Object> getData() {
161169
* exist.
162170
*/
163171
@Nullable
172+
@BetaApi
164173
public <T> T toObject(@Nonnull Class<T> valueType) {
165174
Map<String, Object> data = getData();
166175
return data == null ? null : CustomClassMapper.convertToCustomClass(data, valueType, docRef);
@@ -173,6 +182,7 @@ public <T> T toObject(@Nonnull Class<T> valueType) {
173182
* @param field the path to the field.
174183
* @return true iff the field exists.
175184
*/
185+
@BetaApi
176186
public boolean contains(@Nonnull String field) {
177187
return contains(FieldPath.fromDotSeparatedString(field));
178188
}
@@ -184,6 +194,7 @@ public boolean contains(@Nonnull String field) {
184194
* @param fieldPath the path to the field.
185195
* @return true iff the field exists.
186196
*/
197+
@BetaApi
187198
public boolean contains(@Nonnull FieldPath fieldPath) {
188199
return this.extractField(fieldPath) != null;
189200
}
@@ -195,6 +206,7 @@ public boolean contains(@Nonnull FieldPath fieldPath) {
195206
* @return The value at the given field or null.
196207
*/
197208
@Nullable
209+
@BetaApi
198210
public Object get(@Nonnull String field) {
199211
return get(FieldPath.fromDotSeparatedString(field));
200212
}
@@ -208,6 +220,7 @@ public Object get(@Nonnull String field) {
208220
* @return The value at the given field or null.
209221
*/
210222
@Nullable
223+
@BetaApi
211224
public <T> T get(@Nonnull String field, @Nonnull Class<T> valueType) {
212225
return get(FieldPath.fromDotSeparatedString(field), valueType);
213226
}
@@ -219,6 +232,7 @@ public <T> T get(@Nonnull String field, @Nonnull Class<T> valueType) {
219232
* @return The value at the given field or null.
220233
*/
221234
@Nullable
235+
@BetaApi
222236
public Object get(@Nonnull FieldPath fieldPath) {
223237
Value value = extractField(fieldPath);
224238

@@ -238,6 +252,7 @@ public Object get(@Nonnull FieldPath fieldPath) {
238252
* @return The value at the given field or null.
239253
*/
240254
@Nullable
255+
@BetaApi
241256
public <T> T get(@Nonnull FieldPath fieldPath, Class<T> valueType) {
242257
Object data = get(fieldPath);
243258
return data == null ? null : CustomClassMapper.convertToCustomClass(data, valueType, docRef);
@@ -271,6 +286,7 @@ Value extractField(@Nonnull FieldPath fieldPath) {
271286
* @return The value of the field.
272287
*/
273288
@Nullable
289+
@BetaApi
274290
public Boolean getBoolean(@Nonnull String field) {
275291
return (Boolean) get(field);
276292
}
@@ -283,6 +299,7 @@ public Boolean getBoolean(@Nonnull String field) {
283299
* @return The value of the field.
284300
*/
285301
@Nullable
302+
@BetaApi
286303
public Double getDouble(@Nonnull String field) {
287304
Number number = (Number) get(field);
288305
return number == null ? null : number.doubleValue();
@@ -296,6 +313,7 @@ public Double getDouble(@Nonnull String field) {
296313
* @return The value of the field.
297314
*/
298315
@Nullable
316+
@BetaApi
299317
public String getString(@Nonnull String field) {
300318
return (String) get(field);
301319
}
@@ -308,6 +326,7 @@ public String getString(@Nonnull String field) {
308326
* @return The value of the field.
309327
*/
310328
@Nullable
329+
@BetaApi
311330
public Long getLong(@Nonnull String field) {
312331
Number number = (Number) get(field);
313332
return number == null ? null : number.longValue();
@@ -321,6 +340,7 @@ public Long getLong(@Nonnull String field) {
321340
* @return The value of the field.
322341
*/
323342
@Nullable
343+
@BetaApi
324344
public Date getDate(@Nonnull String field) {
325345
Timestamp timestamp = getTimestamp(field);
326346
return timestamp == null ? null : timestamp.toDate();
@@ -334,6 +354,7 @@ public Date getDate(@Nonnull String field) {
334354
* @return The value of the field.
335355
*/
336356
@Nullable
357+
@BetaApi
337358
public Timestamp getTimestamp(@Nonnull String field) {
338359
return (Timestamp) get(field);
339360
}
@@ -346,6 +367,7 @@ public Timestamp getTimestamp(@Nonnull String field) {
346367
* @return The value of the field.
347368
*/
348369
@Nullable
370+
@BetaApi
349371
public Blob getBlob(@Nonnull String field) {
350372
return (Blob) get(field);
351373
}
@@ -358,6 +380,7 @@ public Blob getBlob(@Nonnull String field) {
358380
* @return The value of the field.
359381
*/
360382
@Nullable
383+
@BetaApi
361384
public GeoPoint getGeoPoint(@Nonnull String field) {
362385
return (GeoPoint) get(field);
363386
}
@@ -368,6 +391,7 @@ public GeoPoint getGeoPoint(@Nonnull String field) {
368391
* @return The reference to the document.
369392
*/
370393
@Nonnull
394+
@BetaApi
371395
public DocumentReference getReference() {
372396
return docRef;
373397
}
@@ -408,6 +432,7 @@ Document.Builder toDocumentPb() {
408432
* @return Whether this DocumentSnapshot is equal to the provided object.
409433
*/
410434
@Override
435+
@BetaApi
411436
public boolean equals(Object obj) {
412437
if (this == obj) {
413438
return true;

0 commit comments

Comments
 (0)