@Nullable
  private DocumentChange modifyDoc(QueryDocumentSnapshot newDocument) {
    ResourcePath resourcePath = newDocument.getReference().getResourcePath();
    DocumentSnapshot oldDocument = documentSet.getDocument(resourcePath);

    if (!oldDocument.getUpdateTime().equals(newDocument.getUpdateTime())) {
      int oldIndex = documentSet.indexOf(resourcePath);
      documentSet = documentSet.remove(resourcePath);
      documentSet = documentSet.add(newDocument);
      int newIndex = documentSet.indexOf(resourcePath);
      return new DocumentChange(newDocument, Type.MODIFIED, oldIndex, newIndex);
    }
    return null;
  }
@ Nullable private DocumentChange modifyDoc ( QueryDocumentSnapshot newDocument ) { ResourcePath resourcePath = newDocument . getReference ( ) . getResourcePath ( ) ; DocumentSnapshot oldDocument = documentSet . getDocument ( resourcePath ) ; if ( ! oldDocument . getUpdateTime ( ) . equals ( newDocument . getUpdateTime ( ) ) ) { int oldIndex = documentSet . indexOf ( resourcePath ) ; documentSet = documentSet . remove ( resourcePath ) ; documentSet = documentSet . add ( newDocument ) ; int newIndex = documentSet . indexOf ( resourcePath ) ; return new DocumentChange ( newDocument , Type . MODIFIED , oldIndex , newIndex ) ; } return null ; }
Applies a document modification to the document tree. Returns the DocumentChange event for
successful modifications.