static int getNumberToReturn(final int limit, final int batchSize, final int numReturnedSoFar) {
    """
	<p>Gets the limit of the number of documents in the OP_REPLY response to the get more request. A value of zero tells the server to
	use the default size. A negative value tells the server to return no more than that number and immediately close the cursor.
	Otherwise, the server will return no more than that number and return the same cursorId to allow the rest of the documents to be
	fetched, if it turns out there are more documents.</p>
	
	<p>The value returned by this method is based on the limit, the batch size, both of which can be positive, negative, or zero, and the
	number of documents fetched so far.</p>
	
	@return the value for numberToReturn in the OP_GET_MORE wire protocol message.
	@mongodb.driver.manual ../meta-driver/latest/legacy/mongodb-wire-protocol/#op-get-more OP_GET_MORE
	@param limit the user-specified limit on the number of results returned
	@param batchSize the user-specified batch size
	@param numReturnedSoFar the number of results returned so far
    """
        int numberToReturn;
        if (Math.abs(limit) != 0) {
            numberToReturn = Math.abs(limit) - numReturnedSoFar;
            if (batchSize != 0 && numberToReturn > Math.abs(batchSize)) {
                numberToReturn = batchSize;
            }
        } else {
            numberToReturn = batchSize;
        }
        return numberToReturn;
    }
static int getNumberToReturn(final int limit, final int batchSize, final int numReturnedSoFar) {
        int numberToReturn;
        if (Math.abs(limit) != 0) {
            numberToReturn = Math.abs(limit) - numReturnedSoFar;
            if (batchSize != 0 && numberToReturn > Math.abs(batchSize)) {
                numberToReturn = batchSize;
            }
        } else {
            numberToReturn = batchSize;
        }
        return numberToReturn;
    }
static int getNumberToReturn ( final int limit , final int batchSize , final int numReturnedSoFar ) { int numberToReturn ; if ( Math . abs ( limit ) != 0 ) { numberToReturn = Math . abs ( limit ) - numReturnedSoFar ; if ( batchSize != 0 && numberToReturn > Math . abs ( batchSize ) ) { numberToReturn = batchSize ; } } else { numberToReturn = batchSize ; } return numberToReturn ; }
<p>Gets the limit of the number of documents in the OP_REPLY response to the get more request. A value of zero tells the server to
use the default size. A negative value tells the server to return no more than that number and immediately close the cursor.
Otherwise, the server will return no more than that number and return the same cursorId to allow the rest of the documents to be
fetched, if it turns out there are more documents.</p>

<p>The value returned by this method is based on the limit, the batch size, both of which can be positive, negative, or zero, and the
number of documents fetched so far.</p>

@return the value for numberToReturn in the OP_GET_MORE wire protocol message.
@mongodb.driver.manual ../meta-driver/latest/legacy/mongodb-wire-protocol/#op-get-more OP_GET_MORE
@param limit the user-specified limit on the number of results returned
@param batchSize the user-specified batch size
@param numReturnedSoFar the number of results returned so far
<p > Gets the limit of the number of documents in the OP_REPLY response to the get more request . A value of zero tells the server to use the default size . A negative value tells the server to return no more than that number and immediately close the cursor . Otherwise the server will return no more than that number and return the same cursorId to allow the rest of the documents to be fetched if it turns out there are more documents . < / p >