Class 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 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
      • fromBsonDocument

        public static ChangeEvent fromBsonDocument​(BsonDocument document)
        Deserializes a BsonDocument into an instance of change event.
        Parameters:
        document - the serialized document
        Returns:
        the deserialized change event