From cac6ce082c6b78fbe5b6c246f8505a76a76a1dde Mon Sep 17 00:00:00 2001 From: William Boxhall Date: Fri, 17 Apr 2020 14:20:49 +1000 Subject: [PATCH] Rename Err to CmdErr to make compiler errors easier to understand --- .../cultureamp/eventsourcing/Configuration.kt | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/kotlin/com/cultureamp/eventsourcing/Configuration.kt b/src/main/kotlin/com/cultureamp/eventsourcing/Configuration.kt index d0aa0e7..8f790bb 100644 --- a/src/main/kotlin/com/cultureamp/eventsourcing/Configuration.kt +++ b/src/main/kotlin/com/cultureamp/eventsourcing/Configuration.kt @@ -4,52 +4,52 @@ import org.joda.time.DateTime import java.util.* import kotlin.reflect.KClass -data class Configuration( +data class Configuration( val creationCommandClass: KClass, val updateCommandClass: KClass, - val create: (CreationCmd) -> Either, - val update: Agg.(UpdateCmd) -> Either>, + val create: (CreationCmd) -> Either, + val update: Agg.(UpdateCmd) -> Either>, val created: (CreationEvt) -> Agg, val updated: Agg.(UpdateEvt) -> Agg, val aggregateType: Agg.() -> String ) { companion object { - inline fun from( - noinline create: (CreationCmd) -> Either, - noinline update: Agg.(UpdateCmd) -> Either>, + inline fun from( + noinline create: (CreationCmd) -> Either, + noinline update: Agg.(UpdateCmd) -> Either>, noinline created: (CreationEvt) -> Agg, noinline updated: Agg.(UpdateEvt) -> Agg = { _ -> this }, noinline aggregateType: Agg.() -> String = { this::class.simpleName!! } - ): Configuration { + ): Configuration { return Configuration(CreationCmd::class, UpdateCmd::class, create, update, created, updated, aggregateType) } - inline fun fromStateless( - noinline create: (CreationCmd) -> Either, - noinline update: (UpdateCmd) -> Either>, + inline fun fromStateless( + noinline create: (CreationCmd) -> Either, + noinline update: (UpdateCmd) -> Either>, instance: Agg, noinline aggregateType: Agg.() -> String = { this::class.simpleName!! } - ): Configuration { + ): Configuration { return from(create, { update(it) }, { instance }, { instance }, aggregateType) } - inline fun > fromTypedAggregate( - aggregateConstructor: AggregateConstructor - ): Configuration { + inline fun > fromTypedAggregate( + aggregateConstructor: AggregateConstructor + ): Configuration { val created = aggregateConstructor::created val create = aggregateConstructor::create - val updated = TypedAggregate::updated - val update = TypedAggregate::update - val aggregateType = TypedAggregate::aggregateType + val updated = TypedAggregate::updated + val update = TypedAggregate::update + val aggregateType = TypedAggregate::aggregateType return from(create, update, created, updated, aggregateType) } - inline fun > fromTypedAggregate( - aggregateConstructor: AggregateConstructorWithProjection, + inline fun > fromTypedAggregate( + aggregateConstructor: AggregateConstructorWithProjection, projection: P - ): Configuration> { - return fromTypedAggregate>(aggregateConstructor.partial(projection)) + ): Configuration> { + return fromTypedAggregate>(aggregateConstructor.partial(projection)) } }