*/
public class GetAllAudienceSegments {
public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
// Get the AudienceSegmentService.
AudienceSegmentServiceInterface audienceSegmentService =
dfpServices.get(session, AudienceSegmentServiceInterface.class);
// Create a statement to select all audience segments.
StatementBuilder statementBuilder = new StatementBuilder()
.orderBy("id ASC")
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get audience segments by statement.
AudienceSegmentPage page =
audienceSegmentService.getAudienceSegmentsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (AudienceSegment audienceSegment : page.getResults()) {