public static BulkWriteResult unacknowledged ( ) { return new BulkWriteResult ( ) { @ Override public boolean wasAcknowledged ( ) { return false ; } @ Override public int getInsertedCount ( ) { throw getUnacknowledgedWriteException ( ) ; } @ Override public int getMatchedCount ( ) { throw getUnacknowledgedWriteException ( ) ; } @ Override public int getDeletedCount ( ) { throw getUnacknowledgedWriteException ( ) ; } @ Override @ Deprecated public boolean isModifiedCountAvailable ( ) { throw getUnacknowledgedWriteException ( ) ; } @ Override public int getModifiedCount ( ) { throw getUnacknowledgedWriteException ( ) ; } @ Override public List < BulkWriteUpsert > getUpserts ( ) { throw getUnacknowledgedWriteException ( ) ; } @ Override public boolean equals ( final Object o ) { if ( this == o ) { return true ; } if ( o == null || getClass ( ) != o . getClass ( ) ) { return false ; } BulkWriteResult that = ( BulkWriteResult ) o ; return ! that . wasAcknowledged ( ) ; } @ Override public int hashCode ( ) { return 0 ; } @ Override public String toString ( ) { return "UnacknowledgedBulkWriteResult{}" ; } private UnsupportedOperationException getUnacknowledgedWriteException ( ) { return new UnsupportedOperationException ( "Cannot get information about an unacknowledged write" ) ; } } ; }
Create an unacknowledged BulkWriteResult