Class ChangeStreamEvent<T>

java.lang.Object
org.springframework.data.mongodb.core.ChangeStreamEvent<T>

public class ChangeStreamEvent<T> extends Object
Message implementation specific to MongoDB Change Streams.
Since:
2.1
Author:
Christoph Strobl, Mark Paluch, Myroslav Kosinskyi
  • Constructor Details

    • ChangeStreamEvent

      public ChangeStreamEvent(@Nullable com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document> raw, Class<T> targetType, MongoConverter converter)
      Parameters:
      raw - can be null.
      targetType - must not be null.
      converter - must not be null.
  • Method Details

    • getRaw

      @Nullable public com.mongodb.client.model.changestream.ChangeStreamDocument<org.bson.Document> getRaw()
      Get the raw ChangeStreamDocument as emitted by the driver.
      Returns:
      can be null.
    • getTimestamp

      @Nullable public Instant getTimestamp()
      Get the cluster time as Instant the event was emitted at.
      Returns:
      can be null.
    • getBsonTimestamp

      @Nullable public org.bson.BsonTimestamp getBsonTimestamp()
      Get the cluster time.
      Returns:
      can be null.
      Since:
      2.2
    • getResumeToken

      @Nullable public org.bson.BsonValue getResumeToken()
      Get the resume token for this event.
      Returns:
      can be null.
    • getOperationType

      @Nullable public com.mongodb.client.model.changestream.OperationType getOperationType()
      Get the operation type for this event.
      Returns:
      can be null.
    • getDatabaseName

      @Nullable public String getDatabaseName()
      Get the database name the event was originated at.
      Returns:
      can be null.
    • getCollectionName

      @Nullable public String getCollectionName()
      Get the collection name the event was originated at.
      Returns:
      can be null.
    • getBody

      @Nullable public T getBody()
      Get the potentially converted ChangeStreamDocument.getFullDocument().
      Returns:
      null when getRaw() or ChangeStreamDocument.getFullDocument() is null.
    • getBodyBeforeChange

      @Nullable public T getBodyBeforeChange()
      Get the potentially converted document before being changed.
      Returns:
      null when getRaw() or ChangeStreamDocument.getFullDocumentBeforeChange() is null.
      Since:
      4.0
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object