Class EmailGenerator

java.lang.Object
de.cuioss.test.generator.domain.EmailGenerator
All Implemented Interfaces:
TypedGenerator<String>

public class EmailGenerator extends Object implements TypedGenerator<String>
Generates syntactically valid email addresses for testing purposes. The generator creates email addresses in the format: firstname.lastname@domain.tld

Example usage:

 var generator = new EmailGenerator();
 String email = generator.next(); // e.g. "john.doe@mail.com"

 // Or create email directly from names
 String email = EmailGenerator.createEmail("john", "doe"); // e.g. "john.doe@example.org"
 
Author:
Oliver Wolff
  • Constructor Details

  • Method Details

    • next

      public String next()
      Description copied from interface: TypedGenerator
      Generates the next instance based on the generator's configuration. Implementations must ensure thread-safety.
      Specified by:
      next in interface TypedGenerator<String>
      Returns:
      A newly created instance. May be null if the generator explicitly supports null value generation.
    • createEmail

      public static String createEmail(String firstname, String lastname)
      Creates an email address from given first and last names. All components are converted to lowercase.
      Parameters:
      firstname - The person's first name, must not be null or empty
      lastname - The person's last name, must not be null or empty
      Returns:
      An email address in the format firstname.lastname@domain.tld. Returns "invalid.email@example.com" if either name component is null or empty.