Class AbstractDomainEvent
java.lang.Object
com.reallifedeveloper.common.domain.event.AbstractDomainEvent
- All Implemented Interfaces:
DomainObject<DomainEvent>,DomainEvent,Serializable
An abstract base class for domain events.
- Author:
- RealLifeDeveloper
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newAbstractDomainEventthat occurred now and has a version of 1.AbstractDomainEvent(int eventVersion) Creates a newAbstractDomainEventthat occurred now and has the given version.AbstractDomainEvent(ZonedDateTime eventOccurredOn) Creates a newAbstractDomainEventthat occurred at the given time and has a version of 1.AbstractDomainEvent(ZonedDateTime eventOccurredOn, int eventVersion) Creates a newAbstractDomainEventthat occurred at the given time and has the given version. -
Method Summary
-
Constructor Details
-
AbstractDomainEvent
public AbstractDomainEvent()Creates a newAbstractDomainEventthat occurred now and has a version of 1.The time of occurrence is taken from calling the
TimeService.now()method on theCommonDomainRegistry.timeService(). -
AbstractDomainEvent
public AbstractDomainEvent(int eventVersion) Creates a newAbstractDomainEventthat occurred now and has the given version.The time of occurrence is taken from calling the
TimeService.now()method on theCommonDomainRegistry.timeService().- Parameters:
eventVersion- the version of the event
-
AbstractDomainEvent
Creates a newAbstractDomainEventthat occurred at the given time and has a version of 1.- Parameters:
eventOccurredOn- the date and time the event occurred
-
AbstractDomainEvent
Creates a newAbstractDomainEventthat occurred at the given time and has the given version.- Parameters:
eventOccurredOn- the time the event occurredeventVersion- the version of the event
-
-
Method Details
-
eventOccurredOn
Description copied from interface:DomainEventGives the time the event occurred.- Specified by:
eventOccurredOnin interfaceDomainEvent- Returns:
- the time the event occurred
-
eventVersion
public int eventVersion()Description copied from interface:DomainEventGives the version of this event. This is useful when deserializing an event.The version should start at 1 and be incremented each time the event class is updated in a way that affects serialization/deserialization.
- Specified by:
eventVersionin interfaceDomainEvent- Returns:
- the version of this event
-
toString
-
hashCode
public int hashCode() -
equals
-
finalize
Make finalize method final to avoid "Finalizer attacks" and corresponding SpotBugs warning (CT_CONSTRUCTOR_THROW).
-