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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAbstractDomainEvent.Builder<ID extends EntityId,TYPE extends AbstractDomainEvent<ID>, BUILDER extends AbstractDomainEvent.Builder<ID, TYPE, BUILDER>> Base class for event builders. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected default constructor for deserialization.AbstractDomainEvent(@NotNull EntityIdPath entityIdPath) Constructor with entity identifier path.AbstractDomainEvent(@NotNull EntityIdPath entityIdPath, @NotNull Event respondTo) Constructor with entity identifier path and event this one responds to.AbstractDomainEvent(@NotNull EntityIdPath entityIdPath, EventId correlationId, EventId causationId) Constructor with entity identifier path, correlation and causation identifiers. -
Method Summary
Modifier and TypeMethodDescriptionfinal AggregateVersionReturns the version of the aggregate the entity belongs to.final IntegerReturns the aggregate version as integer.final IDReturns the identifier of the entity that caused this event.final EntityIdPathReturns the path to the originator of the event.Methods inherited from class org.fuin.ddd4j.ddd.AbstractEvent
equals, getCausationId, getCorrelationId, getEventId, getEventTimestamp, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.fuin.ddd4j.ddd.Event
getCausationId, getCorrelationId, getEventId, getEventTimestamp, getEventType
-
Constructor Details
-
AbstractDomainEvent
protected AbstractDomainEvent()Protected default constructor for deserialization. -
AbstractDomainEvent
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
Description copied from interface:DomainEventReturns the path to the originator of the event.- Specified by:
getEntityIdPathin interfaceDomainEvent<ID extends EntityId>- Returns:
- List of unique identifiers from aggregate root to the entity that emitted the event.
-
getEntityId
Description copied from interface:DomainEventReturns the identifier of the entity that caused this event. This is the last ID in the path.- Specified by:
getEntityIdin interfaceDomainEvent<ID extends EntityId>- Returns:
- Entity identifier.
-
getAggregateVersion
Description copied from interface:DomainEventReturns the version of the aggregate the entity belongs to.- Specified by:
getAggregateVersionin interfaceDomainEvent<ID extends EntityId>- Returns:
- Aggregate version at the time the event was raised.
-
getAggregateVersionInteger
Description copied from interface:DomainEventReturns the aggregate version as integer. This is a null-safe shortcut forgetAggregateVersion().asBaseType()-- Specified by:
getAggregateVersionIntegerin interfaceDomainEvent<ID extends EntityId>- Returns:
- Expected version or null.
-