Class AbstractDomainEvent

java.lang.Object
com.reallifedeveloper.common.domain.event.AbstractDomainEvent
All Implemented Interfaces:
DomainObject<DomainEvent>, DomainEvent, Serializable

public abstract class AbstractDomainEvent extends Object implements DomainEvent
An abstract base class for domain events.
Author:
RealLifeDeveloper
See Also:
  • Constructor Details

    • AbstractDomainEvent

      public AbstractDomainEvent()
      Creates a new AbstractDomainEvent that occurred now and has a version of 1.

      The time of occurrence is taken from calling the TimeService.now() method on the CommonDomainRegistry.timeService().

    • AbstractDomainEvent

      public AbstractDomainEvent(int eventVersion)
      Creates a new AbstractDomainEvent that occurred now and has the given version.

      The time of occurrence is taken from calling the TimeService.now() method on the CommonDomainRegistry.timeService().

      Parameters:
      eventVersion - the version of the event
    • AbstractDomainEvent

      public AbstractDomainEvent(ZonedDateTime eventOccurredOn)
      Creates a new AbstractDomainEvent that occurred at the given time and has a version of 1.
      Parameters:
      eventOccurredOn - the date and time the event occurred
    • AbstractDomainEvent

      public AbstractDomainEvent(ZonedDateTime eventOccurredOn, int eventVersion)
      Creates a new AbstractDomainEvent that occurred at the given time and has the given version.
      Parameters:
      eventOccurredOn - the time the event occurred
      eventVersion - the version of the event
  • Method Details

    • eventOccurredOn

      public ZonedDateTime eventOccurredOn()
      Description copied from interface: DomainEvent
      Gives the time the event occurred.
      Specified by:
      eventOccurredOn in interface DomainEvent
      Returns:
      the time the event occurred
    • eventVersion

      public int eventVersion()
      Description copied from interface: DomainEvent
      Gives 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:
      eventVersion in interface DomainEvent
      Returns:
      the version of this event
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • finalize

      protected final void finalize() throws Throwable
      Make finalize method final to avoid "Finalizer attacks" and corresponding SpotBugs warning (CT_CONSTRUCTOR_THROW).
      Overrides:
      finalize in class Object
      Throws:
      Throwable
      See Also: