Class User
java.lang.Object
com.goldenleaf.shop.model.User
Abstract base entity representing a user in the system.
This is the root of a InheritanceType.JOINED inheritance hierarchy.
Concrete user types such as Customer and Admin extend this class.
Common fields are stored in the users table, while type-specific columns
are stored in their own dedicated tables.
The login field is unique across all user types and is used as the primary
credential identifier. The passwordHash stores the hashed password (e.g. BCrypt).
The lastActivity field is updated on every successful login or meaningful action.
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetId()getLogin()Returns the user's login.voidsetLastActivity(LocalDate lastActivity) Updates the last activity date.voidSets the user's login.voidsetPassword(String hashedPassword)
-
Constructor Details
-
User
public User()Default constructor required by JPA. -
User
Convenience constructor for creating a new user instance.- Parameters:
login- unique loginpasswordHash- already hashed passwordname- display namelastActivity- date of last activity (usuallyLocalDate.now()on creation)- Throws:
EmptyLoginException- if login is blankEmptyLastActivityException- if lastActivity is null
-
-
Method Details
-
getId
-
getLogin
Returns the user's login.- Returns:
- the login
- Throws:
EmptyLoginException- if login is null or blank (should never happen in a persisted entity)
-
setLogin
Sets the user's login.- Parameters:
login- new login value- Throws:
EmptyLoginException- if the provided login is null or blank
-
setPassword
-
getLastActivity
-
setLastActivity
Updates the last activity date.- Parameters:
lastActivity- new activity date- Throws:
EmptyLastActivityException- ifnullis provided
-