code: public static CompactChangeEvent fromBsonDocument(final BsonDocument document) {
      keyPresent(Fields.OPERATION_TYPE_FIELD, document);
      keyPresent(Fields.DOCUMENT_KEY_FIELD, document);
  
      final BsonDocument fullDocument;
      if (document.containsKey(Fields.FULL_DOCUMENT_FIELD)) {
        final BsonValue fdVal = document.get(Fields.FULL_DOCUMENT_FIELD);
        if (fdVal.isDocument()) {
          fullDocument = fdVal.asDocument();
        } else {
          fullDocument = null;
        }
      } else {
        fullDocument = null;
      }
  
      final UpdateDescription updateDescription;
      if (document.containsKey(Fields.UPDATE_DESCRIPTION_FIELD)) {
        updateDescription = UpdateDescription.fromBsonDocument(
            document.getDocument(Fields.UPDATE_DESCRIPTION_FIELD)
        );
      } else {
        updateDescription = null;
      }
  
      final DocumentVersionInfo.Version stitchDocumentVersion;
      if (document.containsKey(Fields.STITCH_DOCUMENT_VERSION_FIELD)) {
        stitchDocumentVersion = DocumentVersionInfo.Version
            .fromBsonDocument(document.getDocument(Fields.STITCH_DOCUMENT_VERSION_FIELD));
      } else {
        stitchDocumentVersion = null;
      }
  
      final Long stitchDocumentHash;
      if (document.containsKey(Fields.STITCH_DOCUMENT_HASH_FIELD)) {
        stitchDocumentHash = document.getInt64(
            Fields.STITCH_DOCUMENT_HASH_FIELD
        ).getValue();
      } else {
        stitchDocumentHash = null;
      }
  
      return new CompactChangeEvent<>(
          OperationType.fromRemote(document.getString(Fields.OPERATION_TYPE_FIELD).getValue()),
          fullDocument,
          document.getDocument(Fields.DOCUMENT_KEY_FIELD),
          updateDescription,
          stitchDocumentVersion,
          stitchDocumentHash,
          document.getBoolean(Fields.WRITE_PENDING_FIELD, BsonBoolean.FALSE).getValue());
    }
docs: Deserializes a {@link BsonDocument} into an instance of change event.
  @param document the serialized document
  @return the deserialized change event