Class DocumentChange

java.lang.Object
com.google.cloud.firestore.DocumentChange

public class DocumentChange extends Object
A DocumentChange represents a change to the documents matching a query. It contains the document affected and a the type of change that occurred (added, modifed, or removed).
  • Method Details

    • getType

      @Nonnull public DocumentChange.Type getType()
    • getDocument

      @Nonnull public QueryDocumentSnapshot getDocument()
      Returns the newly added or modified document if this DocumentChange is for an updated document. Returns the deleted document if this document change represents a removal.
      Returns:
      A snapshot of the new data (for Type.ADDED or Type.MODIFIED) or the removed data (for Type.REMOVED).
    • getOldIndex

      public int getOldIndex()
      The index of the changed document in the result set immediately prior to this DocumentChange (i.e. supposing that all prior DocumentChange objects have been applied). Returns -1 for 'added' events.
    • getNewIndex

      public int getNewIndex()
      The index of the changed document in the result set immediately after this DocumentChange (i.e. supposing that all prior DocumentChange objects and the current DocumentChange object have been applied). Returns -1 for 'removed' events.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object