Class QuerySnapshot (3.7.8)

public abstract class QuerySnapshot implements Iterable<QueryDocumentSnapshot>

A QuerySnapshot contains the results of a query. It can contain zero or more DocumentSnapshot objects.

Inheritance

Object > QuerySnapshot

Static Methods

withChanges(Query query, Timestamp readTime, DocumentSet documentSet, List<DocumentChange> documentChanges)

public static QuerySnapshot withChanges(Query query, Timestamp readTime, DocumentSet documentSet, List<DocumentChange> documentChanges)

Creates a new QuerySnapshot representing a snapshot of a Query with changed documents.

Parameters
NameDescription
queryQuery
readTimecom.google.cloud.Timestamp
documentSetcom.google.cloud.firestore.DocumentSet
documentChangesList<DocumentChange>
Returns
TypeDescription
QuerySnapshot

withDocuments(Query query, Timestamp readTime, List<QueryDocumentSnapshot> documents)

public static QuerySnapshot withDocuments(Query query, Timestamp readTime, List<QueryDocumentSnapshot> documents)

Creates a new QuerySnapshot representing the results of a Query with added documents.

Parameters
NameDescription
queryQuery
readTimecom.google.cloud.Timestamp
documentsList<QueryDocumentSnapshot>
Returns
TypeDescription
QuerySnapshot

Constructors

QuerySnapshot(Query query, Timestamp readTime)

protected QuerySnapshot(Query query, Timestamp readTime)
Parameters
NameDescription
queryQuery
readTimecom.google.cloud.Timestamp

Methods

<T>toObjects(Class<T> clazz)

public List<T> <T>toObjects(Class<T> clazz)

Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as a list.

Parameter
NameDescription
clazzClass<T>

The POJO type used to convert the documents in the list.

Returns
TypeDescription
List<T>

equals(Object obj)

public abstract boolean equals(Object obj)

Returns true if the document data in this QuerySnapshot equals the provided snapshot.

Parameter
NameDescription
objObject

The object to compare against.

Returns
TypeDescription
boolean

Whether this QuerySnapshot is equal to the provided object.

Overrides

getDocumentChanges()

public abstract List<DocumentChange> getDocumentChanges()

Returns the list of documents that changed since the last snapshot. If it's the first snapshot all documents will be in the list as added changes.

Returns
TypeDescription
List<DocumentChange>

The list of documents that changed since the last snapshot.

getDocuments()

public abstract List<QueryDocumentSnapshot> getDocuments()

Returns the documents in this QuerySnapshot as a List in order of the query.

Returns
TypeDescription
List<QueryDocumentSnapshot>

The list of documents.

getQuery()

public Query getQuery()

Returns the query for the snapshot.

Returns
TypeDescription
Query

The backing query that produced this snapshot.

getReadTime()

public Timestamp getReadTime()

Returns the time at which this snapshot was read.

Returns
TypeDescription
com.google.cloud.Timestamp

The read time of this snapshot.

hashCode()

public abstract int hashCode()
Returns
TypeDescription
int
Overrides

isEmpty()

public boolean isEmpty()

Returns true if there are no documents in the QuerySnapshot.

Returns
TypeDescription
boolean

iterator()

public Iterator<QueryDocumentSnapshot> iterator()
Returns
TypeDescription
Iterator<QueryDocumentSnapshot>

size()

public abstract int size()

Returns the number of documents in the QuerySnapshot.

Returns
TypeDescription
int