Class Notification

java.lang.Object
com.pyranid.Notification

@ThreadSafe public final class Notification extends Object
A named database notification received by a NotificationSession.

Notifications are transient, lossy hints rather than durable events. An implementation may coalesce notifications, and the number of returned Notification instances does not represent an underlying event count.

This value deliberately omits any backend-specific sender identifier. Payload nullability and null/empty-string handling are database-specific; Pyranid performs no generic normalization.

Since:
4.6.0
Author:
Mark Allen
  • Method Details

    • of

      public static @NonNull Notification of(@NonNull String channel, @Nullable String payload)
      Creates a notification value.

      This factory enforces the common channel contract but does not apply backend-specific byte limits.

      Parameters:
      channel - nonblank notification channel, which must not contain a NUL character
      payload - notification payload, which may be null or empty
      Returns:
      a notification value
      Throws:
      NullPointerException - if channel is null
      IllegalArgumentException - if channel is blank or contains a NUL character
      Since:
      4.6.0
    • getChannel

      public @NonNull String getChannel()
      Gets the notification channel.
      Returns:
      notification channel
      Since:
      4.6.0
    • getPayload

      public @Nullable String getPayload()
      Gets the notification payload.
      Returns:
      notification payload, which may be null or empty according to backend behavior
      Since:
      4.6.0
    • equals

      public boolean equals(@Nullable Object object)
      Overrides:
      equals in class Object
    • hashCode

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

      public @NonNull String toString()
      Returns a diagnostic representation containing the channel and payload length, but never the payload contents. A non-null payload's length is its Java String.length() in UTF-16 code units, not a backend-specific encoded byte count.
      Overrides:
      toString in class Object
      Returns:
      diagnostic representation of this notification
      Since:
      4.6.0