private static final String EMAIL_ADDRESS = "INSERT_EMAIL_ADDRESS_HERE";
public static void runExample(DfpServices dfpServices, DfpSession session, String emailAddress)
throws Exception {
// Get the UserService.
UserServiceInterface userService = dfpServices.get(session, UserServiceInterface.class);
// Create a statement to select users by email address.
StatementBuilder statementBuilder = new StatementBuilder()
.where("email = :email")
.orderBy("id ASC")
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.withBindVariableValue("email", emailAddress);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get users by statement.
UserPage page = userService.getUsersByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (User user : page.getResults()) {