Package su.onno.ui.notifications
Record Class NotificationRequest
java.lang.Object
java.lang.Record
su.onno.ui.notifications.NotificationRequest
- Record Components:
recipientId- the target user's identity record id (theirCurrentUserResolver.CurrentUser.recordId()), or username for an unlinked login. Required — a request with none is a no-op.type- a short source tag (mention/assignment/…); the UI maps it to an icon. Defaults to"info"when not set.title- the timeline headline. Required.body- optional longer text, ornull.link- thekind/name/idroute the row opens, ornull.actorId- the triggering user's record id, ornull(system-raised).actorName- the triggering user's display name, ornull.actorAvatar- the triggering user's avatar URL, ornull.
public record NotificationRequest(String recipientId, String type, String title, String body, String link, String actorId, String actorName, String actorAvatar)
extends Record
A request to raise one notification, built fluently and handed to
NotificationService.notify(su.onno.ui.notifications.NotificationRequest).
This is the framework's public notification API: any app bean produces a notification by building a
request and calling notify, typically from a Spring @EventListener:
@EventListener
void onApproved(PurchaseApprovedEvent e) {
notifications.notify(NotificationRequest.to(e.requesterId())
.type("approval")
.title("Your purchase was approved")
.link("documents/purchase_orders/" + e.id())
.actor(e.approver())
.build());
}
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theactorAvatarrecord component.actorId()Returns the value of theactorIdrecord component.Returns the value of theactorNamerecord component.body()Returns the value of thebodyrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.link()Returns the value of thelinkrecord component.Returns the value of therecipientIdrecord component.title()Returns the value of thetitlerecord component.static NotificationRequest.BuilderStart a request addressed to a user by their identity record id (or username when unlinked).final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.booleanvalid()Whether this request is deliverable (has a recipient and a title).
-
Constructor Details
-
NotificationRequest
public NotificationRequest(String recipientId, String type, String title, String body, String link, String actorId, String actorName, String actorAvatar) Creates an instance of aNotificationRequestrecord class.- Parameters:
recipientId- the value for therecipientIdrecord componenttype- the value for thetyperecord componenttitle- the value for thetitlerecord componentbody- the value for thebodyrecord componentlink- the value for thelinkrecord componentactorId- the value for theactorIdrecord componentactorName- the value for theactorNamerecord componentactorAvatar- the value for theactorAvatarrecord component
-
-
Method Details
-
to
Start a request addressed to a user by their identity record id (or username when unlinked). -
valid
public boolean valid()Whether this request is deliverable (has a recipient and a title). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
recipientId
Returns the value of therecipientIdrecord component.- Returns:
- the value of the
recipientIdrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
title
Returns the value of thetitlerecord component.- Returns:
- the value of the
titlerecord component
-
body
Returns the value of thebodyrecord component.- Returns:
- the value of the
bodyrecord component
-
link
Returns the value of thelinkrecord component.- Returns:
- the value of the
linkrecord component
-
actorId
Returns the value of theactorIdrecord component.- Returns:
- the value of the
actorIdrecord component
-
actorName
Returns the value of theactorNamerecord component.- Returns:
- the value of the
actorNamerecord component
-
actorAvatar
Returns the value of theactorAvatarrecord component.- Returns:
- the value of the
actorAvatarrecord component
-