@Override protected void setUpResources() throws Exception { paginationConfig.setDefaultPageSize(PaginationConfig.DEFAULT_DEFAULT_PAGE_SIZE); paginationConfig.setMaxPageSize(PaginationConfig.DEFAULT_MAX_PAGE_SIZE); addResource(new ResourceTicketTasksResource(client, paginationConfig)); }
/** * Determine the page size to be used. * * <p>1. If origPageSize is empty, then the one defined in paginationConfig is to be used. 2. If * origPageSize is larger than the maxPageSize defined in paginationConfig, throw exception. * * @param paginationConfig * @param origPageSize * @return */ public static Optional<Integer> determinePageSize( PaginationConfig paginationConfig, Optional<Integer> origPageSize) throws InvalidPageSizeException { if (!origPageSize.isPresent()) { return Optional.of(paginationConfig.getDefaultPageSize()); } else if (origPageSize.get() < 1 || origPageSize.get() > paginationConfig.getMaxPageSize()) { throw new InvalidPageSizeException(origPageSize.get(), 1, paginationConfig.getMaxPageSize()); } else { return origPageSize; } }