32
32
import javax .annotation .Nullable ;
33
33
34
34
/**
35
- * A DocumentSnapshot contains data read from a document in a Firestore database . The data can be
36
- * extracted with the {@link #getData()} or {@link #get(String)} methods.
35
+ * A PipelineResult contains data read from a Firestore Pipeline . The data can be extracted with the
36
+ * {@link #getData()} or {@link #get(String)} methods.
37
37
*
38
- * <p>If the DocumentSnapshot points to a non-existing document, getData() and its corresponding
39
- * methods will return null. You can always explicitly check for a document's existence by calling
40
- * {@link #exists()}.
38
+ * <p>If the PipelineResult represents a non-document result, getReference() will return a null
39
+ * value.
41
40
*
42
41
* <p><b>Subclassing Note</b>: Firestore classes are not meant to be subclassed except for use in
43
42
* test mocks. Subclassing is not supported in production code and new SDK releases may break code
@@ -50,31 +49,30 @@ public final class PipelineResult {
50
49
private final FirestoreRpcContext <?> rpcContext ;
51
50
@ Nullable private final DocumentReference docRef ;
52
51
@ Nullable private final Map <String , Value > fields ;
53
- @ Nullable private final Timestamp readTime ;
52
+ @ Nonnull private final Timestamp executionTime ;
54
53
@ Nullable private final Timestamp updateTime ;
55
54
@ Nullable private final Timestamp createTime ;
56
55
57
56
PipelineResult (
58
57
FirestoreRpcContext <?> rpcContext ,
59
58
@ Nullable DocumentReference docRef ,
60
59
@ Nullable Map <String , Value > fields ,
61
- @ Nullable Timestamp readTime ,
60
+ @ Nonnull Timestamp executionTime ,
62
61
@ Nullable Timestamp updateTime ,
63
62
@ Nullable Timestamp createTime ) { // Elevated access level for mocking.
64
63
this .rpcContext = rpcContext ;
65
64
this .docRef = docRef ;
66
65
this .fields = fields ;
67
- this .readTime = readTime ;
66
+ this .executionTime = executionTime ;
68
67
this .updateTime = updateTime ;
69
68
this .createTime = createTime ;
70
69
}
71
70
72
71
/**
73
- * Returns the ID of the document contained in this snapshot.
74
- *
75
- * @return The id of the document.
72
+ * Returns the ID of the document represented by this result. Returns null if this result is not
73
+ * corresponding to a Firestore document.
76
74
*/
77
- @ Nonnull
75
+ @ Nullable
78
76
@ BetaApi
79
77
public String getId () {
80
78
return docRef .getId ();
@@ -93,23 +91,16 @@ static PipelineResult fromDocument(
93
91
Timestamp .fromProto (document .getCreateTime ()));
94
92
}
95
93
96
- /**
97
- * Returns the time at which this snapshot was read.
98
- *
99
- * @return The read time of this snapshot.
100
- */
94
+ /** Returns the time at which the pipeline producing this result is executed. */
101
95
@ Nullable
102
96
@ BetaApi
103
- public Timestamp getReadTime () {
104
- return readTime ;
97
+ public Timestamp getExecutionTime () {
98
+ return executionTime ;
105
99
}
106
100
107
101
/**
108
- * Returns the time at which this document was last updated. Returns null for non-existing
109
- * documents.
110
- *
111
- * @return The last time the document in the snapshot was updated. Null if the document doesn't
112
- * exist.
102
+ * Returns the time at which this document was last updated. Returns null if this result is not
103
+ * corresponding to a Firestore document.
113
104
*/
114
105
@ Nullable
115
106
@ BetaApi
@@ -118,10 +109,8 @@ public Timestamp getUpdateTime() {
118
109
}
119
110
120
111
/**
121
- * Returns the time at which this document was created. Returns null for non-existing documents.
122
- *
123
- * @return The last time the document in the snapshot was created. Null if the document doesn't
124
- * exist.
112
+ * Returns the time at which this document was created. Returns null if this result is not
113
+ * corresponding to a Firestore document.
125
114
*/
126
115
@ Nullable
127
116
@ BetaApi
@@ -141,12 +130,12 @@ public boolean exists() {
141
130
}
142
131
143
132
/**
144
- * Returns the fields of the document as a Map or null if the document doesn't exist. Field values
133
+ * Returns the fields of the result as a Map or null if the result doesn't exist. Field values
145
134
* will be converted to their native Java representation.
146
135
*
147
- * @return The fields of the document as a Map or null if the document doesn't exist.
136
+ * @return The fields of the document as a Map or null if the result doesn't exist.
148
137
*/
149
- @ Nullable
138
+ @ Nonnull
150
139
@ BetaApi
151
140
public Map <String , Object > getData () {
152
141
if (fields == null ) {
@@ -162,10 +151,10 @@ public Map<String, Object> getData() {
162
151
}
163
152
164
153
/**
165
- * Returns the contents of the document converted to a POJO or null if the document doesn't exist.
154
+ * Returns the contents of the document converted to a POJO or null if the result doesn't exist.
166
155
*
167
156
* @param valueType The Java class to create
168
- * @return The contents of the document in an object of type T or null if the document doesn't
157
+ * @return The contents of the document in an object of type T or null if the result doesn't
169
158
* exist.
170
159
*/
171
160
@ Nullable
@@ -176,7 +165,7 @@ public <T> T toObject(@Nonnull Class<T> valueType) {
176
165
}
177
166
178
167
/**
179
- * Returns whether or not the field exists in the document. Returns false if the document does not
168
+ * Returns whether or not the field exists in the document. Returns false if the result does not
180
169
* exist.
181
170
*
182
171
* @param field the path to the field.
@@ -188,7 +177,7 @@ public boolean contains(@Nonnull String field) {
188
177
}
189
178
190
179
/**
191
- * Returns whether or not the field exists in the document. Returns false if the document does not
180
+ * Returns whether or not the field exists in the document. Returns false if the result does not
192
181
* exist.
193
182
*
194
183
* @param fieldPath the path to the field.
@@ -212,7 +201,7 @@ public Object get(@Nonnull String field) {
212
201
}
213
202
214
203
/**
215
- * Returns the value at the field, converted to a POJO, or null if the field or document doesn't
204
+ * Returns the value at the field, converted to a POJO, or null if the field or result doesn't
216
205
* exist.
217
206
*
218
207
* @param field The path to the field
@@ -244,7 +233,7 @@ public Object get(@Nonnull FieldPath fieldPath) {
244
233
}
245
234
246
235
/**
247
- * Returns the value at the field, converted to a POJO, or null if the field or document doesn't
236
+ * Returns the value at the field, converted to a POJO, or null if the field or result doesn't
248
237
* exist.
249
238
*
250
239
* @param fieldPath The path to the field
@@ -390,7 +379,6 @@ public GeoPoint getGeoPoint(@Nonnull String field) {
390
379
*
391
380
* @return The reference to the document.
392
381
*/
393
- @ Nonnull
394
382
@ BetaApi
395
383
public DocumentReference getReference () {
396
384
return docRef ;
@@ -455,6 +443,6 @@ public int hashCode() {
455
443
public String toString () {
456
444
return String .format (
457
445
"%s{doc=%s, fields=%s, readTime=%s, updateTime=%s, createTime=%s}" ,
458
- getClass ().getSimpleName (), docRef , fields , readTime , updateTime , createTime );
446
+ getClass ().getSimpleName (), docRef , fields , executionTime , updateTime , createTime );
459
447
}
460
448
}
0 commit comments