Interface NameService

All Known Implementing Classes:
SimpleAdjectiveAnimalNameService

public interface NameService
Generates names based on the system configuration.
  • Method Details

    • generateRandomName

      String generateRandomName()
      Generates a randomly assigned name. The returned value is not guaranteed to be unique, as additional steps need to be taken to ensure the name is unique.
      Returns:
      the randomly assigned name
    • generateQualifier

      default String generateQualifier()
      Generates a randomly-assigned qualifier string which is intended to be appended to the generated name. The details of this are up to the implementation, but the default value is a nine-digit random integer. Advanced implementations may use something such as a database lookup or advanced random generator to generate a more complete qualifier code.
      Returns:
      the generated qualifier code
    • generateQualifier

      default String generateQualifier(int max)
      Generates a randomly-assigned qualifier string which is intended to be appended to the generated name. The details of this are up to the implementation, but the default value is a padded integer up to the specified maximum value.
      Returns:
      the generated qualifier code
    • generateQualifiedName

      default String generateQualifiedName()
      Generates a fully qualified name, which is the concatenation of generateRandomName() and generateQualifier()
      Returns:
    • formatAnonymousEmail

      default String formatAnonymousEmail(String name)
      Generates an email address for an anonymous user.
      Parameters:
      name - the username part of the email
      Returns:
      a fully formatted anonymous email
    • assignNameAndEmailIfNecessary

      default User assignNameAndEmailIfNecessary(User user)
      Assigns a generated name and email to the supplied user, if either field is null.
      Parameters:
      user - the user
      Returns:
      the user as it was updated