toDomainEvent
Converts an object to a domain event with full parameter control.
This extension function creates a DomainEvent from any object, allowing complete customization of all event properties. The event metadata is automatically derived from the object's class annotations.
Return
A new DomainEvent instance
Parameters
The type of the event body
The aggregate ID this event belongs to
The ID of the command that triggered this event
The unique event ID (default: generated global ID)
The aggregate version for this event (default: INITIAL_VERSION)
The owner ID of the event (default: DEFAULT_OWNER_ID)
The sequence number within the event stream (default: DEFAULT_EVENT_SEQUENCE)
Whether this is the last event in the stream (default: true)
The event header containing metadata (default: empty header)
The timestamp when the event was created (default: current time)
See also
Converts an object to a domain event using string aggregate identifiers.
This extension function creates a DomainEvent from any object, using string identifiers for aggregate ID and tenant. The named aggregate information is derived from the object's class annotations.
Return
A new DomainEvent instance
Parameters
The type of the event body
The string identifier of the aggregate
The tenant identifier
The ID of the command that triggered this event
The owner ID of the event (default: DEFAULT_OWNER_ID)
The unique event ID (default: generated global ID)
The aggregate version for this event (default: INITIAL_VERSION)
The sequence number within the event stream (default: DEFAULT_EVENT_SEQUENCE)
Whether this is the last event in the stream (default: true)
The event header containing metadata (default: empty header)
The timestamp when the event was created (default: current time)
See also
Throws
if the event type doesn't have a named aggregate getter