Adding QueryDocumentSnapshot#2738
Conversation
| /** | ||
| * A DocumentSnapshot contains data read from a document in a Firestore database. The data can be | ||
| * extracted with the getData or get methods. | ||
| * extracted with the getData() or get() methods. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| Map<String, Object> decodedFields = new HashMap<>(); | ||
| for (Map.Entry<String, Value> entry : fields.entrySet()) { | ||
| decodedFields.put(entry.getKey(), decodeValue(entry.getValue())); | ||
| if (fields != null) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @Override | ||
| public Map<String, Object> getData() { | ||
| Map<String, Object> result = super.getData(); | ||
| Preconditions.checkNotNull(result, "Data in a QueryDocumentSnapshot should be non-null"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @Override | ||
| public <T> T toObject(@Nonnull Class<T> valueType) { | ||
| T result = super.toObject(valueType); | ||
| Preconditions.checkNotNull(result, "Object in a QueryDocumentSnapshot should be non-null"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Some stylistic comments. @garrettjonesgoogle PTAL |
| /** | ||
| * A DocumentSnapshot contains data read from a document in a Firestore database. The data can be | ||
| * extracted with the getData or get methods. | ||
| * extracted with the {@code getData()} or {@code get()} methods. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| @@ -0,0 +1,87 @@ | |||
| /* | |||
| * Copyright 2017 Google Inc. All Rights Reserved. | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| import org.threeten.bp.Instant; | ||
|
|
||
| /** | ||
| * A QueryDocumentSnapshot contains data read from a document in your Firestore database as part of |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
garrettjonesgoogle
left a comment
There was a problem hiding this comment.
LGTM after the copyright line is fixed
| @@ -0,0 +1,87 @@ | |||
| /* | |||
| * Copyright 2018 Google Inc. All Rights Reserved. | |||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Co-authored-by: Lawrence Qiu <lawrenceqiu@google.com>
…v3.36.1 (#2738) * deps: update dependency com.google.cloud:sdk-platform-java-config to v3.36.1 * chore: add program to regenerate reflect-config.json * chore: regenerate reflect-config.json for protobuf 1.68.0 --------- Co-authored-by: BenWhitehead <BenWhitehead@users.noreply.github.com>
This is based on user feedback and changes the DocumentSnapshot API to return
nullfor non-existing documents (instead of throwing an Exception). Since Queries never returnnulldocuments, this PR also introducesQueryDocumentSnapshot, which overrides theDocumentSnapshotmethods to be non-nullable.Addresses b/71489271 and b/69365491