Class ChangeEvent<DocumentT>
- java.lang.Object
-
- com.mongodb.stitch.core.services.mongodb.remote.BaseChangeEvent<DocumentT>
-
- com.mongodb.stitch.core.services.mongodb.remote.ChangeEvent<DocumentT>
-
- Type Parameters:
DocumentT
- The underlying type of document for which this change event was produced.
public final class ChangeEvent<DocumentT> extends BaseChangeEvent<DocumentT>
Represents a change event communicated via a MongoDB change stream. This type of stream always includes a fullDocument for update events, and also includes the change event ID and namespace of the event as returned by MongoDB.
-
-
Constructor Summary
Constructors Constructor Description ChangeEvent(BsonDocument id, OperationType operationType, DocumentT fullDocument, MongoNamespace ns, BsonDocument documentKey, UpdateDescription updateDescription, boolean hasUncommittedWrites)
Constructs a change event.
-
Method Summary
Modifier and Type Method Description static ChangeEvent
fromBsonDocument(BsonDocument document)
Deserializes aBsonDocument
into an instance of change event.BsonDocument
getId()
Returns the ID of the change event itself.MongoNamespace
getNamespace()
The namespace the change relates to.BsonDocument
toBsonDocument()
Serializes this change event into aBsonDocument
.ChangeEvent<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
-
ChangeEvent
public ChangeEvent(BsonDocument id, OperationType operationType, DocumentT fullDocument, MongoNamespace ns, BsonDocument documentKey, UpdateDescription updateDescription, boolean hasUncommittedWrites)
Constructs a change event.- Parameters:
id
- The id of the change event.operationType
- The operation type represented by the change event.fullDocument
- The full document at some point after the change is applied.ns
- The namespace (database and collection) of the document.documentKey
- The id if the underlying document that changed.updateDescription
- The description of what has changed (for updates only).hasUncommittedWrites
- Whether this represents a local uncommitted write.
-
-
Method Detail
-
getId
public BsonDocument getId()
Returns the ID of the change event itself.- Returns:
- the id of this change event.
-
getNamespace
public MongoNamespace getNamespace()
The namespace the change relates to.- Returns:
- the namespace.
-
withoutUncommittedWrites
public ChangeEvent<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 ChangeEvent fromBsonDocument(BsonDocument document)
Deserializes aBsonDocument
into an instance of change event.- Parameters:
document
- the serialized document- Returns:
- the deserialized change event
-
-