Package org.fuin.ddd4j.ddd
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractDomainEvent.Builder<ID extends EntityId,TYPE extends AbstractDomainEvent<ID>,BUILDER extends AbstractDomainEvent.Builder<ID,TYPE,BUILDER>>Base class for event builders.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractDomainEvent()Protected 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AggregateVersiongetAggregateVersion()Returns the version of the aggregate the entity belongs to.IntegergetAggregateVersionInteger()Returns the aggregate version as integer.IDgetEntityId()Returns the identifier of the entity that caused this event.EntityIdPathgetEntityIdPath()Returns the path to the originator of the event.-
Methods inherited from class org.fuin.ddd4j.ddd.AbstractEvent
equals, getCausationId, getCorrelationId, getEventId, getEventTimestamp, hashCode
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.fuin.ddd4j.ddd.Event
getCausationId, getCorrelationId, getEventId, getEventTimestamp, getEventType
-
-
-
-
Constructor Detail
-
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 Detail
-
getEntityIdPath
public final EntityIdPath 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
public final ID 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
@Nullable public final AggregateVersion 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
@Nullable public final Integer 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.
-
-