.orderAscBy("Name")
.offset(offset)
.limit(PAGE_SIZE)
.build();
CampaignPage page = null;
do {
// Get all campaigns.
page = campaignService.get(selector);
// Display campaigns.
if (page.getEntries() != null) {
for (Campaign campaign : page.getEntries()) {
String labels = Joiner.on(", ").join(Lists.transform(
Lists.newArrayList(campaign.getLabels()), new Function<Label, String>() {
public String apply(Label label) {
return String.format("%d/%s", label.getId(), label.getName());
}
}));
System.out.printf("Campaign found with name '%s' and ID %d and labels: %s.%n",
campaign.getName(), campaign.getId(), labels);
}
} else {
System.out.println("No campaigns were found.");
}
offset += PAGE_SIZE;
selector = builder.increaseOffsetBy(PAGE_SIZE).build();
} while (offset < page.getTotalNumEntries());
}