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).
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    An enumeration of snapshot diff types.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if this DocumentChange is equal to the provided object.
    Returns the newly added or modified document if this DocumentChange is for an updated document.
    int
    The index of the changed document in the result set immediately after this DocumentChange (specifically, supposing that all prior DocumentChange objects and the current DocumentChange object have been applied).
    int
    The index of the changed document in the result set immediately prior to this DocumentChange (specifically, supposing that all prior DocumentChange objects have been applied).
     
    int
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • 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 (specifically, 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 (specifically, 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