Class Event<ID>
- Type Parameters:
ID- the aggregate id type
AggregateRootAll you need to do is to inherit from this class when building your own
Event types.
Note: You only have to supply the Aggregate ID, through aggregateId(), for the FIRST/initial Event
that's being applied to the AggregateRoot using the AggregateRoot.apply(Event) method.
Every consecutive Event applied will have its aggregateId(Object) method called IF it doesn't already have a value. I.e. you can be lazy and skip setting the aggregate id
on the Event if you don't want to.
The AggregateRoot also automatically keeps track of the eventOrder() value and will set it for you and ensure that it's growing consecutively.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the id of the aggregate this event relates to.voidaggregateId(ID aggregateId) Set the id of the aggregate this event relates to.Contains the order of the event relative to the aggregate instance (theaggregateId) it relates to
This is also commonly called the sequenceNumber and it's a sequential ever growing number that tracks the order in which events have been stored in theEventStorerelated to a specific aggregate instance (as opposed to the globalOrder that contains the order of ALL events related to a givenAggregateType)voideventOrder(EventOrder eventOrder) Set the event order - called byAggregateRoot
-
Constructor Details
-
Event
public Event()
-
-
Method Details
-
aggregateId
Get the id of the aggregate this event relates to. As a developer you only need to supply this value yourself for the very FIRSTEventthat is being applied
Every consecutiveEventapplied will have itsaggregateId(Object)method called IF it doesn't already have a value. I.e. you can be lazy and skip setting the aggregate id on the Event if you don't want to. -
aggregateId
Set the id of the aggregate this event relates to. As a developer you only need to set this value yourself for the very FIRSTEventthat is being applied
Every consecutiveEventapplied will have itsaggregateId(Object)method called IF it doesn't already have a value. I.e. you can be lazy and skip setting the aggregate id on the Event if you don't want to.- Parameters:
aggregateId- the id of the aggregate this even relates to
-
eventOrder
Contains the order of the event relative to the aggregate instance (theaggregateId) it relates to
This is also commonly called the sequenceNumber and it's a sequential ever growing number that tracks the order in which events have been stored in theEventStorerelated to a specific aggregate instance (as opposed to the globalOrder that contains the order of ALL events related to a givenAggregateType)eventOrder()is zero based, i.e. the first event has order value ZERO (0)The
AggregateRootautomatically keeps track of theeventOrder()value and will set it for you and ensure that it's growing consecutively -
eventOrder
Set the event order - called byAggregateRoot- Parameters:
eventOrder- the order of the event for the aggregate instance the event relates to
-