# Class QueryDocumentSnapshot (3.43.1)

3.43.1 (latest) 3.41.0 3.38.0 3.37.0 3.36.0 3.35.1 3.33.4 3.32.2 3.31.9 3.30.11 3.28.0 3.27.2 3.26.5 3.25.1 3.24.3 3.22.0 3.21.4 3.20.0 3.17.0 3.16.3 3.15.7 3.14.4 3.13.2 3.12.1 3.11.0 3.10.0 3.9.6 3.8.2 3.7.10 3.6.0 3.5.0 3.4.2 3.3.0 3.2.0 3.1.0 3.0.21

    public class QueryDocumentSnapshot extends DocumentSnapshot

A QueryDocumentSnapshot contains data read from a document in a Firestore database as part of a
query. The document is guaranteed to exist and its data can be extracted using the [#getData()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.QueryDocumentSnapshot#com_google_cloud_firestore_QueryDocumentSnapshot_getData__) or #get(String) methods.

QueryDocumentSnapshot offers the same API surface as [DocumentSnapshot](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot). Since query
results contain only existing documents, the #exists() method will always return true and
`getData()` will never be null.

**Subclassing Note**: Firestore classes are not meant to be subclassed except for use in
test mocks. Subclassing is not supported in production code and new SDK releases may break code
that does so.

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> [DocumentSnapshot](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot) \> QueryDocumentSnapshot

## Inherited Members

[DocumentSnapshot.\<T\>get(FieldPath,Class\<T\>)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot__T_get_com_google_cloud_firestore_FieldPath_java_lang_Class_T__) [DocumentSnapshot.\<T\>get(String,Class\<T\>)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot__T_get_java_lang_String_java_lang_Class_T__) [DocumentSnapshot.\<T\>toObject(Class\<T\>)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot__T_toObject_java_lang_Class_T__) [DocumentSnapshot.contains(FieldPath)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_contains_com_google_cloud_firestore_FieldPath_) [DocumentSnapshot.contains(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_contains_java_lang_String_) [DocumentSnapshot.equals(Object)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_equals_java_lang_Object_) [DocumentSnapshot.exists()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_exists__) [DocumentSnapshot.get(FieldPath)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_get_com_google_cloud_firestore_FieldPath_) [DocumentSnapshot.get(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_get_java_lang_String_) [DocumentSnapshot.getBlob(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getBlob_java_lang_String_) [DocumentSnapshot.getBoolean(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getBoolean_java_lang_String_) [DocumentSnapshot.getCreateTime()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getCreateTime__) [DocumentSnapshot.getData()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getData__) [DocumentSnapshot.getDate(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getDate_java_lang_String_) [DocumentSnapshot.getDouble(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getDouble_java_lang_String_) [DocumentSnapshot.getGeoPoint(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getGeoPoint_java_lang_String_) [DocumentSnapshot.getId()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getId__) [DocumentSnapshot.getLong(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getLong_java_lang_String_) [DocumentSnapshot.getReadTime()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getReadTime__) [DocumentSnapshot.getReference()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getReference__) [DocumentSnapshot.getString(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getString_java_lang_String_) [DocumentSnapshot.getTimestamp(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getTimestamp_java_lang_String_) [DocumentSnapshot.getUpdateTime()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getUpdateTime__) [DocumentSnapshot.getVectorValue(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getVectorValue_java_lang_String_) [DocumentSnapshot.hashCode()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_hashCode__) [DocumentSnapshot.toString()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_toString__) [Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Methods

### \<T\>toObject(Class\<T\> valueType)

    public T <T>toObject(Class<T> valueType)

Returns the contents of the document converted to a POJO.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `valueType` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html<T>` The Java class to create |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` | The contents of the document in an object of type T |

**Overrides** [DocumentSnapshot.\<T\>toObject(Class\<T\> valueType)](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot__T_toObject_java_lang_Class_T__)

### getData()

    public Map<String,Object> getData()

Returns the fields of the document as a Map. Field values will be converted to their native
Java representation.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Map.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html,https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html>` | The fields of the document as a Map. |

**Overrides** [DocumentSnapshot.getData()](https://docs.cloud.google.com/java/docs/reference/google-cloud-firestore/latest/com.google.cloud.firestore.DocumentSnapshot#com_google_cloud_firestore_DocumentSnapshot_getData__)