public class DocumentSnapshot extends Object
getData() or get(String) methods.
If the DocumentSnapshot points to a non-existing document, getData() and its corresponding
methods will return null. You can always explicitly check for a document's existence by calling
exists().
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(FieldPath fieldPath)
Returns whether or not the field exists in the document.
|
boolean |
contains(String field)
Returns whether or not the field exists in the document.
|
boolean |
equals(Object obj)
Returns true if the document's data and path in this DocumentSnapshot equals the provided
snapshot.
|
boolean |
exists()
Returns whether or not the field exists in the document.
|
Object |
get(FieldPath fieldPath)
Returns the value at the field or null if the field doesn't exist.
|
Object |
get(String field)
Returns the value at the field or null if the field doesn't exist.
|
Blob |
getBlob(String field)
Returns the value of the field as a Blob.
|
Boolean |
getBoolean(String field)
Returns the value of the field as a boolean.
|
org.threeten.bp.Instant |
getCreateTime()
Returns the time at which this document was created.
|
Map<String,Object> |
getData()
Returns the fields of the document as a Map or null if the document doesn't exist.
|
Date |
getDate(String field)
Returns the value of the field as a Date.
|
Double |
getDouble(String field)
Returns the value of the field as a double.
|
GeoPoint |
getGeoPoint(String field)
Returns the value of the field as a GeoPoint.
|
String |
getId()
Returns the ID of the document contained in this snapshot.
|
Long |
getLong(String field)
Returns the value of the field as a long.
|
org.threeten.bp.Instant |
getReadTime()
Returns the time at which this snapshot was read.
|
DocumentReference |
getReference()
Gets the reference to the document.
|
String |
getString(String field)
Returns the value of the field as a String.
|
org.threeten.bp.Instant |
getUpdateTime()
Returns the time at which this document was last updated.
|
int |
hashCode() |
<T> T |
toObject(Class<T> valueType)
Returns the contents of the document converted to a POJO or null if the document doesn't exist.
|
@Nonnull public String getId()
@Nullable public org.threeten.bp.Instant getReadTime()
@Nullable public org.threeten.bp.Instant getUpdateTime()
@Nullable public org.threeten.bp.Instant getCreateTime()
public boolean exists()
@Nullable public Map<String,Object> getData()
@Nullable public <T> T toObject(@Nonnull Class<T> valueType)
valueType - The Java class to createpublic boolean contains(@Nonnull String field)
field - the path to the field.public boolean contains(@Nonnull FieldPath fieldPath)
fieldPath - the path to the field.@Nullable public Object get(@Nonnull String field)
field - The path to the field.@Nullable public Object get(@Nonnull FieldPath fieldPath)
fieldPath - The path to the field.@Nullable public Boolean getBoolean(@Nonnull String field)
field - The path to the field.RuntimeException - if the value is not a Boolean.@Nullable public Double getDouble(@Nonnull String field)
field - The path to the field.RuntimeException - if the value is not a Number.@Nullable public String getString(@Nonnull String field)
field - The path to the field.RuntimeException - if the value is not a String.@Nullable public Long getLong(@Nonnull String field)
field - The path to the field.RuntimeException - if the value is not a Number.@Nullable public Date getDate(@Nonnull String field)
field - The path to the field.RuntimeException - if the value is not a Date.@Nullable public Blob getBlob(@Nonnull String field)
field - The path to the field.RuntimeException - if the value is not a Blob.@Nullable public GeoPoint getGeoPoint(@Nonnull String field)
field - The path to the field.RuntimeException - if the value is not a GeoPoint.@Nonnull public DocumentReference getReference()
public boolean equals(Object obj)
Copyright © 2018 Google. All rights reserved.