Class CompactChangeEvent<DocumentT>
- java.lang.Object
-
- com.mongodb.stitch.core.services.mongodb.remote.BaseChangeEvent<DocumentT>
-
- com.mongodb.stitch.core.services.mongodb.remote.CompactChangeEvent<DocumentT>
-
- Type Parameters:
DocumentT
- The underlying type of document for which this change event was produced.
public final class CompactChangeEvent<DocumentT> extends BaseChangeEvent<DocumentT>
Represents a change event communicated via a MongoDB change stream from Stitch when watchCompact is called. These change events omit full documents from the event for updates, as well as other fields that are unnecessary in the context of Stitch.
-
-
Constructor Summary
Constructors Constructor Description CompactChangeEvent(OperationType operationType, DocumentT fullDocument, BsonDocument documentKey, UpdateDescription updateDescription, DocumentVersionInfo.Version stitchDocumentVersion, Long stitchDocumentHash, boolean hasUncommittedWrites)
Constructs a change event.
-
Method Summary
Modifier and Type Method Description static CompactChangeEvent
fromBsonDocument(BsonDocument document)
Deserializes aBsonDocument
into an instance of change event.Long
getStitchDocumentHash()
Returns the FNV-1a hash of the document as computed after the rules were applied, and after the document version was removed from the document.DocumentVersionInfo.Version
getStitchDocumentVersion()
Returns the MongoDB Mobile Sync version of the document after this event, if it exists on the document after the update.DocumentVersionInfo
getStitchDocumentVersionInfo()
Returns the MongoDB Mobile Sync version info of the document after this event.BsonDocument
toBsonDocument()
Serializes this change event into aBsonDocument
.CompactChangeEvent<DocumentT>
withoutUncommittedWrites()
Creates a copy of this change event with uncommitted writes flag set to false.-
Methods inherited from class com.mongodb.stitch.core.services.mongodb.remote.BaseChangeEvent
getDocumentKey, getFullDocument, getOperationType, getUpdateDescription, hasUncommittedWrites
-
-
-
-
Constructor Detail
-
CompactChangeEvent
public CompactChangeEvent(@Nonnull OperationType operationType, @Nullable DocumentT fullDocument, @Nonnull BsonDocument documentKey, @Nullable UpdateDescription updateDescription, @Nullable DocumentVersionInfo.Version stitchDocumentVersion, @Nullable Long stitchDocumentHash, boolean hasUncommittedWrites)
Constructs a change event.- Parameters:
operationType
- The operation type represented by the change event.fullDocument
- The full document of this change event (for inserts and updates)documentKey
- The id if the underlying document that changed.updateDescription
- The description of what has changed (for updates only).stitchDocumentVersion
- The Stitch sync version of this document at the time of the event.stitchDocumentHash
- The Stitch sync hash of this document at the time of the event.hasUncommittedWrites
- Whether this represents a local uncommitted write.
-
-
Method Detail
-
getStitchDocumentVersion
@Nullable public DocumentVersionInfo.Version getStitchDocumentVersion()
Returns the MongoDB Mobile Sync version of the document after this event, if it exists on the document after the update.- Returns:
- the sync document version
-
getStitchDocumentVersionInfo
@Nonnull public DocumentVersionInfo getStitchDocumentVersionInfo()
Returns the MongoDB Mobile Sync version info of the document after this event.- Returns:
- the sync document version info
-
getStitchDocumentHash
@Nullable public Long getStitchDocumentHash()
Returns the FNV-1a hash of the document as computed after the rules were applied, and after the document version was removed from the document.- Returns:
- the sync document hash
-
withoutUncommittedWrites
public CompactChangeEvent<DocumentT> withoutUncommittedWrites()
Creates a copy of this change event with uncommitted writes flag set to false.- Returns:
- new change event without uncommitted writes flag
-
toBsonDocument
public BsonDocument toBsonDocument()
Serializes this change event into aBsonDocument
.- Specified by:
toBsonDocument
in classBaseChangeEvent<DocumentT>
- Returns:
- the serialized document.
-
fromBsonDocument
public static CompactChangeEvent fromBsonDocument(BsonDocument document)
Deserializes aBsonDocument
into an instance of change event.- Parameters:
document
- the serialized document- Returns:
- the deserialized change event
-
-