java.lang.Object
com.reallifedeveloper.common.application.notification.NotificationLogId

public final class NotificationLogId extends Object
The ID of a NotificationLog, representing an interval of Notifications that can be held in the log.

The low and high properties of the NotificationLogId refer to the IDs of the StoredEvents represented by the first and last Notifications, respectively.

For a NotificationLog that has been archived, the low and high attributes of the ID exactly match the stored event IDs of the first and last notifications. If the log has not yet been archived, it is not yet "full", so the high attribute may be greater than the stored event ID of the last notification.

For example, an unarchived notification log which can hold 20 notifications may contain only 5 notifications, with stored event IDs 80 through 84. In this case, the NotificationLogId would have a low property of 80 and a high property of 99.

Author:
RealLifeDeveloper
  • Constructor Details

    • NotificationLogId

      public NotificationLogId(long low, long high)
      Creates a new NotificationLogId with the given low and high properties.
      Parameters:
      low - the stored event ID of the first Notification
      high - the stored event ID of the last Notification
      Throws:
      IllegalArgumentException - if low is greater than high
    • NotificationLogId

      public NotificationLogId(String notificationLogId)
      Creates a new NotificationLogId with the low and high properties parsed from a comma-separated string.
      Parameters:
      notificationLogId - a string on the form "<low>,<high>"
      Throws:
      IllegalArgumentException - if the string is null or has the wrong form
  • Method Details

    • externalForm

      public String externalForm()
      Gives a standard string representation of this NotificationLogId, on the form "<low>,<high>".
      Returns:
      a standard string representation of this NotificationLogId
    • low

      public long low()
      Gives the low property of this NotificationLogId, i.e., the stored event ID of the first notification that may be stored in a NotificationLog.
      Returns:
      the low property of this NotificationLogId
    • high

      public long high()
      Gives the high property of this NotificationLogId, i.e., the stored event ID of the last notification that may be stored in a NotificationLog.
      Returns:
      the high property of this NotificationLogId
    • next

      public NotificationLogId next()
      Gives a NotificationLogId representing the next batch of notifications, after the ones in the current NotificationLog.
      Returns:
      a NotificationLogId representing the next batch of notifications
    • previous

      public NotificationLogId previous()
      Gives a NotificationLogId representing the previous batch of notifications, before the ones in the current NotificationLog.
      Returns:
      a NotificationLogId representing the previous batch of notifications
    • batchSize

      public int batchSize()
      Gives the batch size of the NotificationLog with this NotificationLogId, i.e., the number of Notifications it can hold.
      Returns:
      the batch size
    • toString

      public String toString()
      Overrides:
      toString in class Object