// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get custom targeting keys by statement.
CustomTargetingKeyPage page =
customTargetingService.getCustomTargetingKeysByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (CustomTargetingKey customTargetingKey : page.getResults()) {
System.out.printf("%d) Custom targeting key with ID \"%d\", name \"%s\", and "
+ "display name \"%s\" was found.\n", i++, customTargetingKey.getId(),
customTargetingKey.getName(), customTargetingKey.getDisplayName());
customTargetingKeyIds.add(customTargetingKey.getId());
}