java.lang.Object
com.reallifedeveloper.common.application.eventstore.StoredEvent

@Entity public class StoredEvent extends Object
A representation of a DomainEvent that can be stored in a database.
Author:
RealLifeDeveloper
  • Constructor Details

    • StoredEvent

      public StoredEvent(String eventType, String eventBody, ZonedDateTime occurredOn, int version)
      Creates a new StoredEvent with the given attributes.
      Parameters:
      eventType - the class name of the domain event, as given by event.getClass().getName()
      eventBody - a string representation of the domain event
      occurredOn - the date and time the domain event occurred
      version - the version of the domain event
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • id

      public Long id()
      Gives the ID of this StoredEvent. Note that this is not the same as the ID of the domain event itself.
      Returns:
      the ID of this StoredEvent
    • eventType

      public String eventType()
      Gives the class name of the domain event represented by this StoredEvent.
      Returns:
      the class name of the domain event
    • eventBody

      public String eventBody()
      Gives the string representation of the domain event represented by this StoredEvent.
      Returns:
      a string representation of the domain event
    • occurredOn

      public ZonedDateTime occurredOn()
      Gives the date and time the domain event represented by this StoredEvent occurred.
      Returns:
      the date and time the domain event occurred
    • version

      public Integer version()
      Gives the version of the domain event represented by this StoredEvent.
      Returns:
      the version of the domain event
    • toString

      public String toString()
      Overrides:
      toString in class Object