driver-legacy/src/main/com/mongodb/DBCollection.java
@Nullable
    public DBObject findAndModify(@Nullable final DBObject query, @Nullable final DBObject fields, @Nullable final DBObject sort,
                                  final boolean remove, @Nullable final DBObject update,
                                  final boolean returnNew, final boolean upsert) {
        return findAndModify(query, fields, sort, remove, update, returnNew, upsert, 0L, MILLISECONDS);
    }
@Nullable
    public DBObject findAndModify(@Nullable final DBObject query, @Nullable final DBObject fields, @Nullable final DBObject sort,
                                  final boolean remove, @Nullable final DBObject update,
                                  final boolean returnNew, final boolean upsert) {
        return findAndModify(query, fields, sort, remove, update, returnNew, upsert, 0L, MILLISECONDS);
    }
Atomically modify and return a single document. By default, the returned document does not include the modifications made on the
update.

@param query     specifies the selection criteria for the modification
@param fields    a subset of fields to return
@param sort      determines which document the operation will modify if the query selects multiple documents
@param remove    when {@code true}, removes the selected document
@param returnNew when true, returns the modified document rather than the original
@param update    the modifications to apply
@param upsert    when true, operation creates a new document if the query returns no documents
@return the document as it was before the modifications, unless {@code returnNew} is true, in which case it returns the document
after the changes were made
@throws WriteConcernException if the write failed due some other failure specific to the update command
@throws MongoException if the operation failed for some other reason
@mongodb.driver.manual reference/command/findAndModify/ Find and Modify