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 benull
occurredOn
- 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 Notification
create
(DomainEvent event, Long storedEventId) A factory method that sets theeventType
to the name of the event class andoccurredOn
to the date and time when the event occurred.final boolean
Indicates whether some other object is "equal to" this one.event()
Returns the value of theevent
record component.@Nullable String
Returns the value of theeventType
record component.final int
hashCode()
Returns a hash code value for this object.@Nullable ZonedDateTime
Returns the value of theoccurredOn
record component.Returns the value of thestoredEventId
record component.final String
toString()
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
- ifevent
orstoredEventId
isnull
-
-
Method Details
-
create
A factory method that sets theeventType
to the name of the event class andoccurredOn
to the date and time when the event occurred.- Parameters:
event
- the event to store and use to seteventType
andoccurredOn
storedEventId
- the stored event ID to store- Returns:
- a new
Notification
- Throws:
IllegalArgumentException
- ifevent
orstoredEventId
isnull
-
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 theeventType
record component.- Returns:
- the value of the
eventType
record component
-
storedEventId
Returns the value of thestoredEventId
record component.- Returns:
- the value of the
storedEventId
record component
-
occurredOn
Returns the value of theoccurredOn
record component.- Returns:
- the value of the
occurredOn
record component
-
event
Returns the value of theevent
record component.- Returns:
- the value of the
event
record component
-