MutableCommandBuilder

Mutable implementation of CommandBuilder.

This class provides a concrete implementation of the CommandBuilder interface with mutable properties that can be set through the fluent API methods. All properties have sensible defaults and can be modified through method chaining.

Parameters

body

the initial command payload object

See also

Constructors

Link copied to clipboard
constructor(body: Any)

Properties

Link copied to clipboard
open override var aggregateId: String?

the target aggregate instance identifier (optional)

Link copied to clipboard
open override var aggregateVersion: Int?

expected version for optimistic concurrency (optional)

Link copied to clipboard
open override var body: Any

the command payload object

Link copied to clipboard
open override var createTime: Long

timestamp when the command was created

Link copied to clipboard
open override var header: Header

message headers for additional metadata

Link copied to clipboard
open override var id: String
Link copied to clipboard
open override var namedAggregate: NamedAggregate?

the named aggregate information (optional)

Link copied to clipboard
open override var ownerId: String?

the owner identifier of the aggregate (optional)

Link copied to clipboard

whether owner ID should match aggregate ID

Link copied to clipboard
open override var requestId: String?

unique identifier for the request (optional)

Link copied to clipboard
open override var tenantId: String?

the tenant identifier for multi-tenancy (optional)

Link copied to clipboard
open override var upstream: DomainEvent<*>?

the domain event that triggered this command (optional)

Functions

Link copied to clipboard
open override fun aggregateId(aggregateId: String?): CommandBuilder

Sets the target aggregate instance identifier.

Link copied to clipboard
open override fun aggregateVersion(aggregateVersion: Int?): CommandBuilder

Sets the expected aggregate version for optimistic concurrency control.

Link copied to clipboard
open override fun body(body: Any): CommandBuilder

Sets the command body/payload.

Link copied to clipboard
open fun <C> bodyAs(): C

Casts the command body to the specified type.

Link copied to clipboard
open override fun createTime(createTime: Long): CommandBuilder

Sets the creation timestamp for the command message.

Link copied to clipboard
open override fun header(customize: (header: Header) -> Unit): CommandBuilder

Customizes the message header using a lambda function.

open override fun header(header: Header): CommandBuilder

Sets the message header containing additional metadata.

Link copied to clipboard
open override fun id(id: String): CommandBuilder

Sets the unique identifier for the command message.

Link copied to clipboard
open fun localFirst(localFirst: Boolean = true): CommandBuilder

Enables or disables local-first processing mode.

Link copied to clipboard
open override fun namedAggregate(namedAggregate: NamedAggregate): CommandBuilder

Sets the named aggregate information for the command target.

Link copied to clipboard
open override fun ownerId(ownerId: String?): CommandBuilder

Sets the owner identifier of the aggregate.

Link copied to clipboard
open override fun ownerIdSameAsAggregateId(ownerIdSameAsAggregateId: Boolean): CommandBuilder

Sets whether the owner ID should be the same as the aggregate ID.

Link copied to clipboard
open override fun requestId(requestId: String?): CommandBuilder

Sets the request identifier for tracking related commands.

Link copied to clipboard

Sets the request ID only if it's not already set.

Link copied to clipboard
open override fun tenantId(tenantId: String?): CommandBuilder

Sets the tenant identifier for multi-tenancy support.

Link copied to clipboard

Sets the tenant ID only if it's not already set.

Link copied to clipboard

Converts a CommandBuilder to a CommandMessage.

Link copied to clipboard
open override fun upstream(upstream: DomainEvent<*>): CommandBuilder

Sets the upstream domain event that triggered this command.