Class UsernameGenerator

java.lang.Object
com.serinity.accesscontrol.util.UsernameGenerator

public final class UsernameGenerator extends Object
Utility class for generating unique, sanitized usernames based on email addresses.

This class provides a single static method generate(String) which takes an email address, removes any non-alphanumeric characters from the local part, converts it to lowercase, and appends a short random UUID suffix to ensure uniqueness.

Designed to be used when creating Profile entities to automatically generate immutable usernames.

Note: The class is declared final and has no public constructor, as it is a pure utility class.


// Example usage
String username = UsernameGenerator.generate("John.Doe@example.com"); // Result might be "johndoe_a1b2c3"
Since:
2026-02-03
Version:
1.0
Author:
@ZouariOmar (zouariomar20@gmail.com)
See Also:
  • Constructor Details

    • UsernameGenerator

      public UsernameGenerator()
  • Method Details