// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get activity groups by statement.
ActivityGroupPage page =
activityGroupService.getActivityGroupsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (ActivityGroup activityGroup : page.getResults()) {
System.out.printf(
"%d) Activity group with ID \"%d\" and name \"%s\" was found.\n", i++,
activityGroup.getId(), activityGroup.getName());
}
}