Record Class Notification

java.lang.Object
java.lang.Record
com.reallifedeveloper.common.application.notification.Notification
Record Components:
eventType - the type of the event
storedEventId - the stored event ID, must not be null
occurredOn - the timestamp the event occurred
event - the domain event that occurred, must not be null

public record Notification(@Nullable String eventType, Long storedEventId, @Nullable ZonedDateTime occurredOn, DomainEvent event) extends Record
A notification is information about a domain event that has occurred, and that has been stored in an EventStore. The notification can be sent to external systems that need to be informed about the event.
Author:
RealLifeDeveloper
  • Constructor Details

  • Method Details

    • create

      public static Notification create(DomainEvent event, Long storedEventId)
      A factory method that sets the eventType to the name of the event class and occurredOn to the date and time when the event occurred.
      Parameters:
      event - the event to store and use to set eventType and occurredOn
      storedEventId - the stored event ID to store
      Returns:
      a new Notification
      Throws:
      IllegalArgumentException - if event or storedEventId is null
    • 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.
    • eventType

      public @Nullable String eventType()
      Returns the value of the eventType record component.
      Returns:
      the value of the eventType record component
    • storedEventId

      public Long storedEventId()
      Returns the value of the storedEventId record component.
      Returns:
      the value of the storedEventId record component
    • occurredOn

      public @Nullable ZonedDateTime occurredOn()
      Returns the value of the occurredOn record component.
      Returns:
      the value of the occurredOn record component
    • event

      public DomainEvent event()
      Returns the value of the event record component.
      Returns:
      the value of the event record component