long (long pagesAmount, SearchTaskOptions options) { if (options.searchForwardDirection) { if (options.leftBoundPageNumber == -1) { return 0; } else { return options.leftBoundPageNumber; } } else { if (options.rightBoundPageNumber == -1) { return pagesAmount - 1; } else { return options.rightBoundPageNumber; } } }