getOrInitialize

fun getOrInitialize(key: NamedAggregate): IdGenerator

Retrieves or initializes an IdGenerator for the given NamedAggregate.

This method checks if an IdGenerator is already associated with the provided key. If not, it attempts to create one using the available factories. The first factory that successfully creates a non-null IdGenerator is used. If no factory can create an IdGenerator, an IllegalStateException is thrown.

Return

the IdGenerator associated with the key

Parameters

key

the NamedAggregate for which to retrieve or initialize the IdGenerator

Throws

if no AggregateIdGeneratorFactory can create an IdGenerator for the key