SimpleStateAggregate

class SimpleStateAggregate<S : Any>(val aggregateId: AggregateId, val metadata: StateAggregateMetadata<S>, val state: S, var ownerId: String = OwnerId.DEFAULT_OWNER_ID, var version: Int = Version.UNINITIALIZED_VERSION, var eventId: String = "", var firstOperator: String = "", var operator: String = "", var firstEventTime: Long = 0, var eventTime: Long = 0, var deleted: Boolean = false) : StateAggregate<S> , TypedAggregate<S>

A simple implementation of StateAggregate that manages aggregate state through event sourcing.

This class applies domain events to update the aggregate's state, handles ownership transfers, deletion, and recovery events, and maintains versioning for consistency.

Parameters

S

The type of the aggregate state.

Constructors

Link copied to clipboard
constructor(aggregateId: AggregateId, metadata: StateAggregateMetadata<S>, state: S, ownerId: String = OwnerId.DEFAULT_OWNER_ID, version: Int = Version.UNINITIALIZED_VERSION, eventId: String = "", firstOperator: String = "", operator: String = "", firstEventTime: Long = 0, eventTime: Long = 0, deleted: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val aggregateId: AggregateId

The unique identifier of the aggregate.

Link copied to clipboard
open override val aggregateType: Class<S>
Link copied to clipboard
open override var deleted: Boolean

Indicates whether the aggregate has been deleted. Defaults to false.

Link copied to clipboard
open override var eventId: String

The ID of the last processed event. Defaults to an empty string.

Link copied to clipboard
open override var eventTime: Long

The timestamp of the last event. Defaults to 0.

Link copied to clipboard
Link copied to clipboard
open override var firstEventTime: Long

The timestamp of the first event. Defaults to 0.

Link copied to clipboard
open override var firstOperator: String

The operator who initiated the first event. Defaults to an empty string.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Metadata describing the state aggregate, including sourcing functions.

Link copied to clipboard
open override var operator: String

The operator who initiated the last event. Defaults to an empty string.

Link copied to clipboard
open override var ownerId: String

The identifier of the current owner of the aggregate. Defaults to OwnerId.DEFAULT_OWNER_ID.

Link copied to clipboard
open override val state: S

The current state of the aggregate.

Link copied to clipboard
open override var version: Int

The current version of the aggregate. Defaults to Version.UNINITIALIZED_VERSION.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun onSourcing(eventStream: DomainEventStream): StateAggregate<S>

Applies a stream of domain events to update the aggregate's state.

Link copied to clipboard
fun AggregateIdCapable.toGroupKey(parallelism: Int = DEFAULT_PARALLELISM): Int

Computes a grouping key for parallel processing based on the aggregate ID.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun toString(): String