java.lang.Object
jku.se.Notification
Represents an in-app notification that can be sent to users or administrators.
Supports message tracking and timestamping.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Notification
(String message) Constructs a simple Notification with a given message and current timestamp.Notification
(String message, boolean isForAdmin, String targetUserEmail) Constructs a new Notification with full attributes. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Clears the list of all sent messages (mainly for tests/debugging).Returns the formatted timestamp as a string.Returns the full notification text including timestamp.getId()
Returns the unique ID of the notification.Returns the message content of the notification.Returns the timestamp when the notification was created.Returns the notification message without timestamp (for user notifications).void
Sends an in-app notification for a given user.void
void
setTimestamp
(LocalDateTime timestamp)
-
Field Details
-
MESSAGES_SENT
-
-
Constructor Details
-
Notification
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
Constructs a simple Notification with a given message and current timestamp.- Parameters:
message
- The notification message.
-
-
Method Details
-
sendInApp
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
Returns the message content of the notification.- Returns:
- The notification message.
-
getId
Returns the unique ID of the notification.- Returns:
- The notification ID.
-
getTimestamp
Returns the timestamp when the notification was created.- Returns:
- The timestamp.
-
getFormattedTimestamp
Returns the formatted timestamp as a string.- Returns:
- Formatted timestamp string.
-
getFullMessage
Returns the full notification text including timestamp.- Returns:
- Full notification text.
-
getUserMessage
Returns the notification message without timestamp (for user notifications).- Returns:
- Notification message without timestamp.
-
setId
-
setTimestamp
-