Class Event<ID>
- java.lang.Object
-
- dk.cloudcreate.essentials.components.eventsourced.aggregates.stateful.classic.Event<ID>
-
- Type Parameters:
ID- the aggregate id type
public abstract class Event<ID> extends Object
Based Event type that's built to work in combination withAggregateRoot
All you need to do is to inherit from this class when building your ownEventtypes.Note: You only have to supply the Aggregate ID, through
aggregateId(), for the FIRST/initialEventthat's being applied to theAggregateRootusing theAggregateRoot.apply(Event)method.
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.
TheAggregateRootalso automatically keeps track of theeventOrder()value and will set it for you and ensure that it's growing consecutively.
-
-
Constructor Summary
Constructors Constructor Description Event()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IDaggregateId()Get the id of the aggregate this event relates to.voidaggregateId(ID aggregateId)Set the id of the aggregate this event relates to.dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrdereventOrder()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(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder eventOrder)Set the event order - called byAggregateRoot
-
-
-
Method Detail
-
aggregateId
public ID 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
public void aggregateId(ID 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
public dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder 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
public void eventOrder(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder eventOrder)
Set the event order - called byAggregateRoot- Parameters:
eventOrder- the order of the event for the aggregate instance the event relates to
-
-