protected PaginatedList<DTO> findPaginatedWithQueryAndSort(DBQuery.Query query, DBSort.SortBuilder sort, int page, int perPage) {
        try (final DBCursor<DTO> cursor = db.find(query)
                .sort(sort)
                .limit(perPage)
                .skip(perPage * Math.max(0, page - 1))) {
            return new PaginatedList<>(asImmutableList(cursor), cursor.count(), page, perPage);
        }
    }
protected PaginatedList < DTO > findPaginatedWithQueryAndSort ( DBQuery . Query query , DBSort . SortBuilder sort , int page , int perPage ) { try ( final DBCursor < DTO > cursor = db . find ( query ) . sort ( sort ) . limit ( perPage ) . skip ( perPage * Math . max ( 0 , page - 1 ) ) ) { return new PaginatedList < > ( asImmutableList ( cursor ) , cursor . count ( ) , page , perPage ) ; } }
Returns a {@link PaginatedList<DTO>} for the given query and pagination parameters.
<p>
This method is only accessible by subclasses to avoid exposure of the {@link DBQuery} and {@link DBSort}
interfaces to consumers.

@param query the query to execute
@param sort the sort builder for the query
@param page the page number that should be returned
@param perPage the number of entries per page
@return the paginated list