Class QuerySnapshot

java.lang.Object
com.google.cloud.firestore.QuerySnapshot
All Implemented Interfaces:
Iterable<QueryDocumentSnapshot>

public abstract class QuerySnapshot extends Object implements Iterable<QueryDocumentSnapshot>
A QuerySnapshot contains the results of a query. It can contain zero or more DocumentSnapshot objects.
  • Constructor Details

    • QuerySnapshot

      protected QuerySnapshot(Query query, com.google.cloud.Timestamp readTime)
  • Method Details

    • withDocuments

      public static QuerySnapshot withDocuments(Query query, com.google.cloud.Timestamp readTime, List<QueryDocumentSnapshot> documents)
      Creates a new QuerySnapshot representing the results of a Query with added documents.
    • withChanges

      public static QuerySnapshot withChanges(Query query, com.google.cloud.Timestamp readTime, com.google.cloud.firestore.DocumentSet documentSet, List<DocumentChange> documentChanges)
      Creates a new QuerySnapshot representing a snapshot of a Query with changed documents.
    • getQuery

      @Nonnull public Query getQuery()
      Returns the query for the snapshot.
      Returns:
      The backing query that produced this snapshot.
    • getReadTime

      @Nonnull public com.google.cloud.Timestamp getReadTime()
      Returns the time at which this snapshot was read.
      Returns:
      The read time of this snapshot.
    • getDocuments

      @Nonnull public abstract List<QueryDocumentSnapshot> getDocuments()
      Returns the documents in this QuerySnapshot as a List in order of the query.
      Returns:
      The list of documents.
    • getDocumentChanges

      @Nonnull 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:
      The list of documents that changed since the last snapshot.
    • isEmpty

      public boolean isEmpty()
      Returns true if there are no documents in the QuerySnapshot.
    • size

      public abstract int size()
      Returns the number of documents in the QuerySnapshot.
    • iterator

      Specified by:
      iterator in interface Iterable<QueryDocumentSnapshot>
    • toObjects

      @Nonnull public <T> List<T> toObjects(@Nonnull Class<T> clazz)
      Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as a list.
      Parameters:
      clazz - The POJO type used to convert the documents in the list.
    • equals

      public abstract boolean equals(Object obj)
      Returns true if the document data in this QuerySnapshot equals the provided snapshot.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare against.
      Returns:
      Whether this QuerySnapshot is equal to the provided object.
    • hashCode

      public abstract int hashCode()
      Overrides:
      hashCode in class Object