Interface NameService
- All Known Implementing Classes:
SimpleAdjectiveAnimalNameService
public interface NameService
Generates names based on the system configuration.
-
Method Summary
Modifier and TypeMethodDescriptiondefault User
Assigns a generated name and email to the supplied user, if either field is null.default String
formatAnonymousEmail
(String name) Generates an email address for an anonymous user.default String
Generates a fully qualified name, which is the concatenation ofgenerateRandomName()
andgenerateQualifier()
default String
Generates a randomly-assigned qualifier string which is intended to be appended to the generated name.default String
generateQualifier
(int max) Generates a randomly-assigned qualifier string which is intended to be appended to the generated name.Generates a randomly assigned name.
-
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
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
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
Generates a fully qualified name, which is the concatenation ofgenerateRandomName()
andgenerateQualifier()
- Returns:
-
formatAnonymousEmail
Generates an email address for an anonymous user.- Parameters:
name
- the username part of the email- Returns:
- a fully formatted anonymous email
-
assignNameAndEmailIfNecessary
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
-