toAggregateIdGetterIfAnnotated
Creates a property getter for the aggregate ID if the property is annotated with @AggregateId.
This method scans the property for the @AggregateId annotation and, if present, converts the property to a string getter for accessing the aggregate identifier.
Example usage:
class OrderCommand(
@AggregateId
val orderId: String
)
val command = OrderCommand("order-123")
val idGetter = OrderCommand::orderId.toAggregateIdGetterIfAnnotated()
val id = idGetter?.get(command) // Returns "order-123"Content copied to clipboard
Return
a PropertyGetter for the aggregate ID, or null if the property is not annotated
Parameters
T
the type of the object containing the property
See also
Throws
if the annotated property is not of type String