Class User

java.lang.Object
example.app.entities.users.User
All Implemented Interfaces:
FileDatabaseCompatible, Serializable
Direct Known Subclasses:
FacultyUser

public class User extends Object implements Serializable, FileDatabaseCompatible

Class User

  • This class represents a user account.
  • Each user has a unique ID (UUID v4) assigned to them which cannot be changed.
  • Each user has a account creation date assigned to them at the time of their account creation.
  • The password for each user is stored in a byte array, which is created by the encrypting the
  • password with SHA512 algorithm.
  • If two user have same username, then they are considered equal, else they aren't
See Also:
  • Method Details

    • getId

      public UUID getId()
      Getter for the ID
      Specified by:
      getId in interface FileDatabaseCompatible
      Returns:
      The id of the user
    • getUsername

      public String getUsername()
      Getter for the username
      Returns:
      The username of the user
    • setUsername

      public void setUsername(String username) throws NullArgumentException, EmptyArgumentException
      Setter for the username
      Parameters:
      username - The username of the user
      Throws:
      NullArgumentException - If the username is null
      EmptyArgumentException - If the username is empty
    • setPassword

      public void setPassword(String password) throws NullArgumentException, EmptyArgumentException
      Setter for the password
      Parameters:
      password - The password of the user
      Throws:
      NullArgumentException - If the password is null
      EmptyArgumentException - If the password is empty
    • getFirstName

      public String getFirstName()
      Getter for the first name
      Returns:
      the first name
    • setFirstName

      public void setFirstName(String firstName) throws NullArgumentException, EmptyArgumentException
      Setter for the first name
      Parameters:
      firstName - The first name of the user
      Throws:
      NullArgumentException - If the first name is null
      EmptyArgumentException - If the first name is empty
    • getLastName

      public String getLastName()
      Getter for the last name
      Returns:
      the last name
    • setLastName

      public void setLastName(String lastName) throws NullArgumentException, EmptyArgumentException
      Setter for the last name
      Parameters:
      lastName - The last name of the user
      Throws:
      NullArgumentException - If the last name is null
      EmptyArgumentException - If the last name is empty
    • getEmail

      public String getEmail()
      Getter for the email
      Returns:
      The email of the user
    • setEmail

      public void setEmail(String email) throws NullArgumentException, EmptyArgumentException
      Setter for the email
      Parameters:
      email - The email of the user
      Throws:
      NullArgumentException - If the email is null
      EmptyArgumentException - If the email is empty
    • getCreationDate

      public LocalDateTime getCreationDate()
      Getter for the account creation date
      Specified by:
      getCreationDate in interface FileDatabaseCompatible
      Returns:
      The account creation date
    • usernameEquals

      public boolean usernameEquals(String username)
      This method checks if a username is equal to the username of the user or not
      Parameters:
      username - The username to be checked
      Returns:
      true if the username is equal to the username of the user, false otherwise
    • passwordEquals

      public boolean passwordEquals(String password)
      This method checks if a password is equal to the password of the user or not
      Parameters:
      password - The password to be checked
      Returns:
      true if the password is equal to the password of the user, false otherwise
    • credentialsEquals

      public boolean credentialsEquals(String username, String password)
      This method checks if a given username and password are equal to the user or not
      Parameters:
      username - The username to be checked
      password - The password to be checked
      Returns:
      true if the username and password are equal to the user, false otherwise
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object