Skip to content
Martin Caslavsky edited this page Oct 30, 2017 · 4 revisions

Multiple GoodData REST resources return results in the form of pages. Each page contains limited number of records and a URL link to next page (except the last page).

GoodData Java SDK encapsulates this resources as listItem(Page page) methods:

  • paging can be controlled by the Page argument - eg. listItem(new PageRequest(10)) lists 10 items per page
  • the return type is PageableList<Item> which represents a page returned from REST resource
  • the PageableList class has methods boolean hasNextPage() and Page getNextPage() which can be used to iterate thru all pages
  • the paging flow can be simplified using PageableList's iterator which transparently loads subsequent pages, so eg. for each loop iterates thru all pages
  • Java Stream API is supported, so when PageableList.stream() is used, it processes all the items including those on subsequent pages
  • to work only with items on the current page use list.getCurrentPageItems() method
Clone this wiki locally