Class AbstractDomainEvent<ID extends EntityId>

java.lang.Object
org.fuin.ddd4j.ddd.AbstractEvent
org.fuin.ddd4j.ddd.AbstractDomainEvent<ID>
Type Parameters:
ID - Type of the entity identifier.
All Implemented Interfaces:
Serializable, DomainEvent<ID>, Event

public abstract class AbstractDomainEvent<ID extends EntityId> extends AbstractEvent implements DomainEvent<ID>
Base class for domain events.
See Also:
  • Constructor Details

    • AbstractDomainEvent

      protected AbstractDomainEvent()
      Protected default constructor for deserialization.
    • AbstractDomainEvent

      public AbstractDomainEvent(@NotNull @NotNull EntityIdPath entityIdPath)
      Constructor with entity identifier path.
      Parameters:
      entityIdPath - Identifier path from aggregate root to the entity that emitted the event.
    • AbstractDomainEvent

      public AbstractDomainEvent(@NotNull @NotNull EntityIdPath entityIdPath, @NotNull @NotNull Event respondTo)
      Constructor with entity identifier path and event this one responds to. Convenience method to set the correlation and causation identifiers correctly.
      Parameters:
      entityIdPath - Identifier path from aggregate root to the entity that emitted the event.
      respondTo - Causing event.
    • AbstractDomainEvent

      public AbstractDomainEvent(@NotNull @NotNull EntityIdPath entityIdPath, @Nullable EventId correlationId, @Nullable EventId causationId)
      Constructor with entity identifier path, correlation and causation identifiers.
      Parameters:
      entityIdPath - Identifier path from aggregate root to the entity that emitted the event.
      correlationId - Correlation ID.
      causationId - ID of the event that caused this one.
  • Method Details

    • getEntityIdPath

      public final EntityIdPath getEntityIdPath()
      Description copied from interface: DomainEvent
      Returns the path to the originator of the event.
      Specified by:
      getEntityIdPath in interface DomainEvent<ID extends EntityId>
      Returns:
      List of unique identifiers from aggregate root to the entity that emitted the event.
    • getEntityId

      public final ID getEntityId()
      Description copied from interface: DomainEvent
      Returns the identifier of the entity that caused this event. This is the last ID in the path.
      Specified by:
      getEntityId in interface DomainEvent<ID extends EntityId>
      Returns:
      Entity identifier.
    • getAggregateVersion

      @Nullable public final AggregateVersion getAggregateVersion()
      Description copied from interface: DomainEvent
      Returns the version of the aggregate the entity belongs to.
      Specified by:
      getAggregateVersion in interface DomainEvent<ID extends EntityId>
      Returns:
      Aggregate version at the time the event was raised.
    • getAggregateVersionInteger

      @Nullable public final Integer getAggregateVersionInteger()
      Description copied from interface: DomainEvent
      Returns the aggregate version as integer. This is a null-safe shortcut for getAggregateVersion().asBaseType()-
      Specified by:
      getAggregateVersionInteger in interface DomainEvent<ID extends EntityId>
      Returns:
      Expected version or null.