Package com.mongodb
Class WriteConcernResult
- java.lang.Object
-
- com.mongodb.WriteConcernResult
-
public abstract class WriteConcernResult extends Object
The result of a successful write operation. If the write was unacknowledged, thenwasAcknowledgedwill return false and all other methods will throwMongoUnacknowledgedWriteException.- Since:
- 3.0
- See Also:
WriteConcern.UNACKNOWLEDGED
-
-
Constructor Summary
Constructors Constructor Description WriteConcernResult()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static WriteConcernResultacknowledged(int count, boolean isUpdateOfExisting, BsonValue upsertedId)Create an acknowledged WriteConcernResultabstract intgetCount()Returns the number of documents affected by the write operation.abstract BsonValuegetUpsertedId()Returns the value of _id if this write resulted in an upsert.abstract booleanisUpdateOfExisting()Returns true if the write was an update of an existing document.static WriteConcernResultunacknowledged()Create an unacknowledged WriteConcernResultabstract booleanwasAcknowledged()Returns true if the write was acknowledged.
-
-
-
Method Detail
-
wasAcknowledged
public abstract boolean wasAcknowledged()
Returns true if the write was acknowledged.- Returns:
- true if the write was acknowledged
-
getCount
public abstract int getCount()
Returns the number of documents affected by the write operation.- Returns:
- the number of documents affected by the write operation
- Throws:
UnsupportedOperationException- if the write was unacknowledged.
-
isUpdateOfExisting
public abstract boolean isUpdateOfExisting()
Returns true if the write was an update of an existing document.- Returns:
- true if the write was an update of an existing document
- Throws:
UnsupportedOperationException- if the write was unacknowledged.
-
getUpsertedId
@Nullable public abstract BsonValue getUpsertedId()
Returns the value of _id if this write resulted in an upsert.- Returns:
- the value of _id if this write resulted in an upsert.
- Throws:
UnsupportedOperationException- if the write was unacknowledged.
-
acknowledged
public static WriteConcernResult acknowledged(int count, boolean isUpdateOfExisting, @Nullable BsonValue upsertedId)
Create an acknowledged WriteConcernResult- Parameters:
count- the count of matched documentsisUpdateOfExisting- whether an existing document was updatedupsertedId- if an upsert resulted in an inserted document, this is the _id of that document. This may be null- Returns:
- an acknowledged WriteConcernResult
-
unacknowledged
public static WriteConcernResult unacknowledged()
Create an unacknowledged WriteConcernResult- Returns:
- an unacknowledged WriteConcernResult
-
-