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 with AggregateRoot
All 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the id of the aggregate this event relates to.
    void
    aggregateId(ID aggregateId)
    Set the id of the aggregate this event relates to.
    dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder
    Contains the order of the event relative to the aggregate instance (the aggregateId) 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 the EventStore related to a specific aggregate instance (as opposed to the globalOrder that contains the order of ALL events related to a given AggregateType)
    void
    eventOrder(dk.cloudcreate.essentials.components.eventsourced.eventstore.postgresql.types.EventOrder eventOrder)
    Set the event order - called by AggregateRoot

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Event

      public Event()
  • Method Details

    • 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 FIRST Event that is being applied
      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.
    • 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 FIRST Event that is being applied
      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.
      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 (the aggregateId) 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 the EventStore related to a specific aggregate instance (as opposed to the globalOrder that contains the order of ALL events related to a given AggregateType)

      eventOrder() is zero based, i.e. the first event has order value ZERO (0)

      The AggregateRoot automatically keeps track of the eventOrder() 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 by AggregateRoot
      Parameters:
      eventOrder - the order of the event for the aggregate instance the event relates to