DocumentChange
public class DocumentChange
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, modified, or removed).
Subclassing Note: Cloud 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.
Summary
Nested types |
|---|
public enum DocumentChange.TypeAn enumeration of snapshot diff types. |
Public fields |
|
|---|---|
final QueryDocumentSnapshot |
|
final int |
The index in the new snapshot, after processing all previous changes. |
final int |
The index in the old snapshot, after processing all previous changes. |
final DocumentChange.Type |
Public methods |
|
|---|---|
boolean |
|
@NonNull QueryDocumentSnapshot |
Returns the newly added or modified document if this |
int |
The index of the changed document in the result set immediately after this |
int |
The index of the changed document in the result set immediately prior to this |
@NonNull DocumentChange.Type |
getType() |
int |
hashCode() |
Public fields
newIndex
public final int newIndex
The index in the new snapshot, after processing all previous changes.
oldIndex
public final int oldIndex
The index in the old snapshot, after processing all previous changes.
Public methods
getDocument
public @NonNull 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 | |
|---|---|
@NonNull QueryDocumentSnapshot |
A snapshot of the new data (for |
getNewIndex
public int getNewIndex()
The index of the changed document in the result set immediately after this
DocumentChange (assuming that all prior DocumentChange objects and the current
DocumentChange object have been applied). Returns -1 for 'removed' events.
getOldIndex
public int getOldIndex()
The index of the changed document in the result set immediately prior to this
DocumentChange (assuming that all prior DocumentChange objects have been applied). Returns -1 for 'added' events.