Skip to content

Commit

Permalink
Eliminate duplicate email addresses. Fixes #388
Browse files Browse the repository at this point in the history
  • Loading branch information
szarnyasg committed May 3, 2022
1 parent 2131160 commit 59d0032
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,14 @@ private Person generatePerson() {
base = base.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
base = base.replaceAll(" ", ".");
base = base.replaceAll("[.]+", ".");
for (int i = 0; i < numEmails; i++) {
while (person.getEmails().size() < numEmails) {
String email = base + "" + person.getAccountId() + "@" +
Dictionaries.emails.getRandomEmail(randomFarm.get(RandomGeneratorFarm.Aspect.TOP_EMAIL),
randomFarm.get(RandomGeneratorFarm.Aspect.EMAIL));
person.getEmails().add(email);
// avoid duplicates
if (!person.getEmails().contains(email)) {
person.getEmails().add(email);
}
}

// Set class year
Expand Down

0 comments on commit 59d0032

Please sign in to comment.