Record Class Notification
java.lang.Object
java.lang.Record
com.reallifedeveloper.common.application.notification.Notification
- Record Components:
eventType- the type of the eventstoredEventId- the stored event ID, must not benulloccurredOn- the timestamp the event occurredevent- the domain event that occurred, must not benull
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 Summary
ConstructorsConstructorDescriptionNotification(@Nullable String eventType, Long storedEventId, @Nullable ZonedDateTime occurredOn, DomainEvent event) Creates a newNotification. -
Method Summary
Modifier and TypeMethodDescriptionstatic Notificationcreate(DomainEvent event, Long storedEventId) A factory method that sets theeventTypeto the name of the event class andoccurredOnto the date and time when the event occurred.final booleanIndicates whether some other object is "equal to" this one.event()Returns the value of theeventrecord component.@Nullable StringReturns the value of theeventTyperecord component.final inthashCode()Returns a hash code value for this object.@Nullable ZonedDateTimeReturns the value of theoccurredOnrecord component.Returns the value of thestoredEventIdrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Notification
public Notification(@Nullable String eventType, Long storedEventId, @Nullable ZonedDateTime occurredOn, DomainEvent event) Creates a newNotification.- Throws:
IllegalArgumentException- ifeventorstoredEventIdisnull
-
-
Method Details
-
create
A factory method that sets theeventTypeto the name of the event class andoccurredOnto the date and time when the event occurred.- Parameters:
event- the event to store and use to seteventTypeandoccurredOnstoredEventId- the stored event ID to store- Returns:
- a new
Notification - Throws:
IllegalArgumentException- ifeventorstoredEventIdisnull
-
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). -
eventType
Returns the value of theeventTyperecord component.- Returns:
- the value of the
eventTyperecord component
-
storedEventId
Returns the value of thestoredEventIdrecord component.- Returns:
- the value of the
storedEventIdrecord component
-
occurredOn
Returns the value of theoccurredOnrecord component.- Returns:
- the value of the
occurredOnrecord component
-
event
Returns the value of theeventrecord component.- Returns:
- the value of the
eventrecord component
-