Module Lunchify
Package jku.se

Class Notification

java.lang.Object
jku.se.Notification

public class Notification extends Object
Represents an in-app notification that can be sent to users or administrators. Supports message tracking and timestamping.
  • Field Details

    • MESSAGES_SENT

      public static final List<String> MESSAGES_SENT
  • Constructor Details

    • Notification

      public Notification(String message, boolean isForAdmin, String targetUserEmail)
      Constructs a new Notification with full attributes.
      Parameters:
      message - The notification message.
      isForAdmin - Whether the notification is intended for an admin.
      targetUserEmail - The email of the target user (can be null).
    • Notification

      public Notification()
      Default constructor. Creates an empty message with current timestamp and no target.
    • Notification

      public Notification(String message)
      Constructs a simple Notification with a given message and current timestamp.
      Parameters:
      message - The notification message.
  • Method Details

    • sendInApp

      public void sendInApp(User user, String message)
      Sends an in-app notification for a given user.
      Parameters:
      user - The target user.
      message - The message to send.
    • clearMessages

      public static void clearMessages()
      Clears the list of all sent messages (mainly for tests/debugging).
    • getMessage

      public String getMessage()
      Returns the message content of the notification.
      Returns:
      The notification message.
    • getId

      public String getId()
      Returns the unique ID of the notification.
      Returns:
      The notification ID.
    • getTimestamp

      public LocalDateTime getTimestamp()
      Returns the timestamp when the notification was created.
      Returns:
      The timestamp.
    • getFormattedTimestamp

      public String getFormattedTimestamp()
      Returns the formatted timestamp as a string.
      Returns:
      Formatted timestamp string.
    • getFullMessage

      public String getFullMessage()
      Returns the full notification text including timestamp.
      Returns:
      Full notification text.
    • getUserMessage

      public String getUserMessage()
      Returns the notification message without timestamp (for user notifications).
      Returns:
      Notification message without timestamp.
    • setId

      public void setId(String id)
    • setTimestamp

      public void setTimestamp(LocalDateTime timestamp)