Record Class NotificationRequest

java.lang.Object
java.lang.Record
su.onno.ui.notifications.NotificationRequest
Record Components:
recipientId - the target user's identity record id (their CurrentUserResolver.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, or null.
link - the kind/name/id route the row opens, or null.
actorId - the triggering user's record id, or null (system-raised).
actorName - the triggering user's display name, or null.
actorAvatar - the triggering user's avatar URL, or null.

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());
 }
 
  • 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 a NotificationRequest record class.
      Parameters:
      recipientId - the value for the recipientId record component
      type - the value for the type record component
      title - the value for the title record component
      body - the value for the body record component
      link - the value for the link record component
      actorId - the value for the actorId record component
      actorName - the value for the actorName record component
      actorAvatar - the value for the actorAvatar record component
  • Method Details

    • to

      public static NotificationRequest.Builder to(String recipientId)
      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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • recipientId

      public String recipientId()
      Returns the value of the recipientId record component.
      Returns:
      the value of the recipientId record component
    • type

      public String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • title

      public String title()
      Returns the value of the title record component.
      Returns:
      the value of the title record component
    • body

      public String body()
      Returns the value of the body record component.
      Returns:
      the value of the body record component
    • link

      public String link()
      Returns the value of the link record component.
      Returns:
      the value of the link record component
    • actorId

      public String actorId()
      Returns the value of the actorId record component.
      Returns:
      the value of the actorId record component
    • actorName

      public String actorName()
      Returns the value of the actorName record component.
      Returns:
      the value of the actorName record component
    • actorAvatar

      public String actorAvatar()
      Returns the value of the actorAvatar record component.
      Returns:
      the value of the actorAvatar record component