Class Session


  • public final class Session
    extends java.lang.Object
    An object representing a user login session.
    Since:
    1.4.0, 1.5.0 Updated to add open time and duration
    • Constructor Summary

      Constructors 
      Constructor Description
      Session​(java.lang.String username, UserRole userRole)
      Creates an instance of a session.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.time.Duration getDuration()
      Returns a Duration object containing the elapsed time the session has been opened.
      java.lang.String getDurationFullString()
      Returns a string of the elapsed time the session has been opened in sentence format.
      java.lang.String getDurationString()
      Returns a string of the elapsed time the session has been opened in the format 00:00:00.
      java.lang.String getDurationStringLong()
      Returns a string of the elapsed time the session has been opened in the format 00:00:00.0000.
      java.time.LocalDateTime getOpenTime()
      Returns a LocalDateTime object containing the timestamp when the session was opened.
      java.lang.String getUsername()
      Returns the username of the logged in user.
      UserRole getUserRole()
      Returns the user role of the logged in user.
      int hashCode()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Session

        public Session​(java.lang.String username,
                       UserRole userRole)
        Creates an instance of a session.
        Parameters:
        username - the username of the logged in user
        userRole - the user role of the logged in user
    • Method Detail

      • getUsername

        public java.lang.String getUsername()
        Returns the username of the logged in user.
        Returns:
        the username of the logged in user
      • getUserRole

        public UserRole getUserRole()
        Returns the user role of the logged in user.
        Returns:
        the user role of the logged in user
      • getOpenTime

        public java.time.LocalDateTime getOpenTime()
        Returns a LocalDateTime object containing the timestamp when the session was opened.
        Returns:
        a LocalDateTime object containing the timestamp when the session was opened
        Since:
        1.5.0
      • getDuration

        public java.time.Duration getDuration()
        Returns a Duration object containing the elapsed time the session has been opened.
        Returns:
        a Duration object containing the elapsed time the session has been opened
        Since:
        1.5.0
      • getDurationString

        public java.lang.String getDurationString()
        Returns a string of the elapsed time the session has been opened in the format 00:00:00.
        Returns:
        a string of the elapsed time the session has been opened in the format 00:00:00
        Since:
        1.5.0
      • getDurationStringLong

        public java.lang.String getDurationStringLong()
        Returns a string of the elapsed time the session has been opened in the format 00:00:00.0000.
        Returns:
        a string of the elapsed time the session has been opened in the format 00:00:00.0000
        Since:
        1.5.0
      • getDurationFullString

        public java.lang.String getDurationFullString()
        Returns a string of the elapsed time the session has been opened in sentence format.
        Returns:
        a string of the elapsed time the session has been opened in sentence format
        Since:
        1.5.0
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object