Package io.realm.mongodb.mongo.events
Class UpdateDescription
- java.lang.Object
-
- io.realm.mongodb.mongo.events.UpdateDescription
-
public final class UpdateDescription extends Object
Indicates which fields have been modified in a given update operation.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static UpdateDescription
diff(BsonDocument beforeDocument, BsonDocument afterDocument)
Find the diff between two documents.boolean
equals(Object obj)
static UpdateDescription
fromBsonDocument(BsonDocument document)
Converts an update description BSON document from a MongoDB Change Event into an UpdateDescription object.Collection<String>
getRemovedFields()
Returns aList
containing the field names that have been removed in the corresponding update.BsonDocument
getUpdatedFields()
Returns aBsonDocument
containing keys and values representing (respectively) the fields that have changed in the corresponding update and their new values.int
hashCode()
boolean
isEmpty()
Determines whether this update description is empty.UpdateDescription
merge(UpdateDescription otherDescription)
Unilaterally merge an update description into this update description.BsonDocument
toBsonDocument()
Converts this update description to its document representation as it would appear in a MongoDB Change Event.BsonDocument
toUpdateDocument()
Convert this update description to an update document.
-
-
-
Method Detail
-
getUpdatedFields
public BsonDocument getUpdatedFields()
Returns aBsonDocument
containing keys and values representing (respectively) the fields that have changed in the corresponding update and their new values.- Returns:
- the updated field names and their new values.
-
getRemovedFields
public Collection<String> getRemovedFields()
Returns aList
containing the field names that have been removed in the corresponding update.- Returns:
- the removed fields names.
-
toUpdateDocument
public BsonDocument toUpdateDocument()
Convert this update description to an update document.- Returns:
- an update document with the appropriate $set and $unset documents.
-
toBsonDocument
public BsonDocument toBsonDocument()
Converts this update description to its document representation as it would appear in a MongoDB Change Event.- Returns:
- the update description document as it would appear in a change event
-
fromBsonDocument
public static UpdateDescription fromBsonDocument(BsonDocument document)
Converts an update description BSON document from a MongoDB Change Event into an UpdateDescription object.- Parameters:
document
- the- Returns:
- the converted UpdateDescription
-
merge
public UpdateDescription merge(@Nullable UpdateDescription otherDescription)
Unilaterally merge an update description into this update description.- Parameters:
otherDescription
- the update description to merge into this- Returns:
- this merged update description
-
diff
public static UpdateDescription diff(@Nullable BsonDocument beforeDocument, @Nullable BsonDocument afterDocument)
Find the diff between two documents.NOTE: This does not do a full diff on [BsonArray]. If there is an inequality between the old and new array, the old array will simply be replaced by the new one.
- Parameters:
beforeDocument
- original documentafterDocument
- document to diff on- Returns:
- a description of the updated fields and removed keys between the documents.
-
isEmpty
public boolean isEmpty()
Determines whether this update description is empty.- Returns:
- true if the update description is empty, false otherwise
-
-