int offset = 0;
// To get all express businesses owned by the current customer,
// simply skip the call to SelectorBuilder.equals below
Selector selector = new SelectorBuilder()
.fields("Id", "Name", "Website", "Address", "GeoPoint", "Status")
.equals("Status", ExpressBusinessStatus.ENABLED.getValue())
.offset(offset)
.limit(PAGE_SIZE)
.build();
List<ExpressBusiness> businesses = Lists.newArrayList();
ExpressBusinessPage page;
do {
// Get all businesses.
page = businessService.get(selector);
// Display businesses.
if (page.getTotalNumEntries() > 0) {
for (ExpressBusiness business : page.getEntries()) {
System.out.printf("Express business found with name '%s' id %d website: %s "
+ "address: %s geo point: %s status: %s%n",
business.getName(),
business.getId(),
business.getWebsite(),
toString(business.getAddress()),
toString(business.getGeoPoint()),
business.getStatus().getValue());
businesses.add(business);
}
} else {
System.out.println("No express businesses were found.");
}
offset += PAGE_SIZE;
selector.getPaging().setStartIndex(offset);
} while (offset < page.getTotalNumEntries());
System.out.printf("Found %d express businesses in total%n", businesses.size());
return businesses;