StateEventData

data class StateEventData<S : Any>(val delegate: DomainEventStream, val state: S, val firstOperator: String = delegate.header.operator.orEmpty(), val firstEventTime: Long = delegate.createTime, val deleted: Boolean = false) : StateEvent<S> , Decorator<DomainEventStream> , DomainEventStream

Data class implementation of StateEvent that wraps a DomainEventStream with state information.

Parameters

delegate

the domain event stream being wrapped

state

the state of the aggregate

firstOperator

the first operator (default: from delegate header)

firstEventTime

the first event time (default: from delegate)

deleted

whether the aggregate is deleted (default: false)

Constructors

Link copied to clipboard
constructor(delegate: DomainEventStream, state: S, firstOperator: String = delegate.header.operator.orEmpty(), firstEventTime: Long = delegate.createTime, deleted: Boolean = false)

Properties

Link copied to clipboard
open override val aggregateId: AggregateId

The aggregate ID this event stream belongs to

Link copied to clipboard
open override val aggregateName: String
Link copied to clipboard
open override val body: List<DomainEvent<*>>
Link copied to clipboard
open override val commandId: String
Link copied to clipboard
open override val contextName: String
Link copied to clipboard
open override val createTime: Long
Link copied to clipboard
open override val delegate: DomainEventStream
Link copied to clipboard
open override val deleted: Boolean
Link copied to clipboard
open override val eventId: String

The event ID, delegated to the id property.

Link copied to clipboard
open override val eventTime: Long

The time when the event occurred, delegated to createTime.

Link copied to clipboard
Link copied to clipboard
open override val firstEventTime: Long
Link copied to clipboard
open override val firstOperator: String
Link copied to clipboard
open override val header: Header
Link copied to clipboard
open override val id: String
Link copied to clipboard
open override val initialized: Boolean
Link copied to clipboard
open override val isInitialVersion: Boolean
Link copied to clipboard
open override val isReadOnly: Boolean
Link copied to clipboard
open override val operator: String

The operator who triggered the event, from the header.

Link copied to clipboard
open override val ownerId: String
Link copied to clipboard
open override val requestId: String
Link copied to clipboard
open override val size: Int

The number of events in this stream

Link copied to clipboard
open override val state: S
Link copied to clipboard
open override val version: Int

用于生成领域事件版本号.

Functions

Link copied to clipboard
fun NamedAggregate.aggregateId(id: String = generateId(), tenantId: String = TenantId.DEFAULT_TENANT_ID): DefaultAggregateId

Creates an AggregateId for this NamedAggregate with the specified parameters.

Link copied to clipboard

Finds the aggregate type class associated with this named aggregate.

Link copied to clipboard

Converts this NamedAggregate to its corresponding AggregateMetadata.

Link copied to clipboard
open override fun copy(): StateEvent<S>

Creates a copy of this StateEventData with a copied delegate.

Link copied to clipboard

Generates a unique ID string for this NamedAggregate.

Link copied to clipboard
fun NamedBoundedContext.getContextAlias(boundedContext: BoundedContext? = MetadataSearcher.metadata.contexts[contextName]): String
Link copied to clipboard

Gets the context alias prefix for this bounded context.

Link copied to clipboard

Determines if this event stream should be ignored during event sourcing.

Link copied to clipboard

Checks if the named aggregate is available locally at runtime.

Link copied to clipboard
open override fun isSameAggregateName(other: NamedAggregate): Boolean
Link copied to clipboard
Link copied to clipboard
open operator override fun iterator(): Iterator<DomainEvent<*>>
Link copied to clipboard
fun Message<*, *>.match(function: FunctionInfo): Boolean

Checks if this message matches the given function for compensation purposes.

Link copied to clipboard

Finds the aggregate type class associated with this named aggregate, throwing an exception if not found.

Link copied to clipboard

Sorts an iterable collection based on Order annotations and dependencies.

Link copied to clipboard

Extension function to convert a NamedAggregate to an EventNamedAggregate.

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

Converts this NamedAggregate to its string representation.

Link copied to clipboard
Link copied to clipboard

Converts a DomainEventStream to a StateEvent using the state from a ReadOnlyStateAggregate.

fun <S : Any> DomainEventStream.toStateEvent(state: S, firstOperator: String = header.operator.orEmpty(), firstEventTime: Long = createTime, deleted: Boolean = false): StateEvent<S>

Converts a DomainEventStream to a StateEvent with the given state.

Link copied to clipboard

Converts this NamedAggregate to a string representation using the context alias.

Link copied to clipboard
open override fun withHeader(additionalSource: Map<String, String>): DomainEventStream
open override fun withHeader(key: String, value: String): DomainEventStream
Link copied to clipboard
open override fun withReadOnly(): DomainEventStream