AggregateMetadata

data class AggregateMetadata<C : Any, S : Any>(val namedAggregate: NamedAggregate, val staticTenantId: String?, val state: StateAggregateMetadata<S>, val command: CommandAggregateMetadata<C>) : NamedAggregateDecorator, Metadata

Represents the metadata for an aggregate, combining state and command aggregate metadata.

This data class encapsulates all the metadata required to work with an aggregate, including its named aggregate information, static tenant ID, state aggregate metadata, and command aggregate metadata. It provides utilities for extracting aggregate IDs and determining if the aggregate follows an aggregation pattern.

Parameters

C

The type of the command aggregate.

S

The type of the state aggregate.

Constructors

Link copied to clipboard
constructor(namedAggregate: NamedAggregate, staticTenantId: String?, state: StateAggregateMetadata<S>, command: CommandAggregateMetadata<C>)

Creates a new AggregateMetadata with the specified named aggregate, tenant ID, and metadata.

Properties

Link copied to clipboard
open override val aggregateName: String
Link copied to clipboard

The metadata for the command aggregate.

Link copied to clipboard
open override val contextName: String
Link copied to clipboard

Determines if this aggregate follows an aggregation pattern where state and command aggregates are different types.

Link copied to clipboard
open override val namedAggregate: NamedAggregate

The named aggregate that this metadata belongs to.

Link copied to clipboard

The metadata for the state aggregate.

Link copied to clipboard

The static tenant ID configured for this aggregate, or null if not configured.

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.

fun AggregateMetadata<*, *>.aggregateId(id: String = generateId(), tenantId: String = staticTenantId ?: TenantId.DEFAULT_TENANT_ID): DefaultAggregateId

Creates an AggregateId for this AggregateMetadata 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 operator override fun equals(other: Any?): Boolean
Link copied to clipboard
fun extractAggregateId(state: S, aggregateId: String, tenantId: String = TenantId.DEFAULT_TENANT_ID): AggregateId
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
open override fun hashCode(): Int
Link copied to clipboard

Checks if the named aggregate is available locally at runtime.

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

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

Link copied to clipboard

Extension function to convert a NamedAggregate to an EventNamedAggregate.

Link copied to clipboard

Converts this NamedAggregate to its string representation.

Link copied to clipboard
fun <S : Any> AggregateMetadata<*, S>.toStateAggregate(state: S, version: Int, ownerId: String = OwnerId.DEFAULT_OWNER_ID, eventId: String = "", firstOperator: String = "", operator: String = "", firstEventTime: Long = 0, eventTime: Long = 0, deleted: Boolean = false, aggregateId: String = "", tenantId: String = TenantId.DEFAULT_TENANT_ID): StateAggregate<S>
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard

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