Skip to content

Commit

Permalink
Rename Err to CmdErr to make compiler errors easier to understand
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboxhall committed Apr 17, 2020
1 parent f31d4d7 commit cac6ce0
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/main/kotlin/com/cultureamp/eventsourcing/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,52 @@ import org.joda.time.DateTime
import java.util.*
import kotlin.reflect.KClass

data class Configuration<CreationCmd : CreationCommand, CreationEvt : CreationEvent, Err : CommandError, UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, Agg : Aggregate>(
data class Configuration<CreationCmd : CreationCommand, CreationEvt : CreationEvent, CmdErr : CommandError, UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, Agg : Aggregate>(
val creationCommandClass: KClass<CreationCmd>,
val updateCommandClass: KClass<UpdateCmd>,
val create: (CreationCmd) -> Either<Err, CreationEvt>,
val update: Agg.(UpdateCmd) -> Either<Err, List<UpdateEvt>>,
val create: (CreationCmd) -> Either<CmdErr, CreationEvt>,
val update: Agg.(UpdateCmd) -> Either<CmdErr, List<UpdateEvt>>,
val created: (CreationEvt) -> Agg,
val updated: Agg.(UpdateEvt) -> Agg,
val aggregateType: Agg.() -> String
) {
companion object {

inline fun <reified CreationCmd : CreationCommand, CreationEvt : CreationEvent, Err : CommandError, reified UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, reified Agg : Aggregate> from(
noinline create: (CreationCmd) -> Either<Err, CreationEvt>,
noinline update: Agg.(UpdateCmd) -> Either<Err, List<UpdateEvt>>,
inline fun <reified CreationCmd : CreationCommand, CreationEvt : CreationEvent, CmdErr : CommandError, reified UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, reified Agg : Aggregate> from(
noinline create: (CreationCmd) -> Either<CmdErr, CreationEvt>,
noinline update: Agg.(UpdateCmd) -> Either<CmdErr, List<UpdateEvt>>,
noinline created: (CreationEvt) -> Agg,
noinline updated: Agg.(UpdateEvt) -> Agg = { _ -> this },
noinline aggregateType: Agg.() -> String = { this::class.simpleName!! }
): Configuration<CreationCmd, CreationEvt, Err, UpdateCmd, UpdateEvt, Agg> {
): Configuration<CreationCmd, CreationEvt, CmdErr, UpdateCmd, UpdateEvt, Agg> {
return Configuration(CreationCmd::class, UpdateCmd::class, create, update, created, updated, aggregateType)
}

inline fun <reified CreationCmd : CreationCommand, CreationEvt : CreationEvent, Err : CommandError, reified UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, reified Agg : Aggregate> fromStateless(
noinline create: (CreationCmd) -> Either<Err, CreationEvt>,
noinline update: (UpdateCmd) -> Either<Err, List<UpdateEvt>>,
inline fun <reified CreationCmd : CreationCommand, CreationEvt : CreationEvent, CmdErr : CommandError, reified UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, reified Agg : Aggregate> fromStateless(
noinline create: (CreationCmd) -> Either<CmdErr, CreationEvt>,
noinline update: (UpdateCmd) -> Either<CmdErr, List<UpdateEvt>>,
instance: Agg,
noinline aggregateType: Agg.() -> String = { this::class.simpleName!! }
): Configuration<CreationCmd, CreationEvt, Err, UpdateCmd, UpdateEvt, Agg> {
): Configuration<CreationCmd, CreationEvt, CmdErr, UpdateCmd, UpdateEvt, Agg> {
return from(create, { update(it) }, { instance }, { instance }, aggregateType)
}

inline fun <reified CreationCmd : CreationCommand, CreationEvt : CreationEvent, Err : CommandError, reified UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, reified Agg : TypedAggregate<UpdateCmd, UpdateEvt, Err, Agg>> fromTypedAggregate(
aggregateConstructor: AggregateConstructor<CreationCmd, CreationEvt, Err, UpdateCmd, UpdateEvt, Agg>
): Configuration<CreationCmd, CreationEvt, Err, UpdateCmd, UpdateEvt, Agg> {
inline fun <reified CreationCmd : CreationCommand, CreationEvt : CreationEvent, CmdErr : CommandError, reified UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, reified Agg : TypedAggregate<UpdateCmd, UpdateEvt, CmdErr, Agg>> fromTypedAggregate(
aggregateConstructor: AggregateConstructor<CreationCmd, CreationEvt, CmdErr, UpdateCmd, UpdateEvt, Agg>
): Configuration<CreationCmd, CreationEvt, CmdErr, UpdateCmd, UpdateEvt, Agg> {
val created = aggregateConstructor::created
val create = aggregateConstructor::create
val updated = TypedAggregate<UpdateCmd, UpdateEvt, Err, Agg>::updated
val update = TypedAggregate<UpdateCmd, UpdateEvt, Err, Agg>::update
val aggregateType = TypedAggregate<UpdateCmd, UpdateEvt, Err, Agg>::aggregateType
val updated = TypedAggregate<UpdateCmd, UpdateEvt, CmdErr, Agg>::updated
val update = TypedAggregate<UpdateCmd, UpdateEvt, CmdErr, Agg>::update
val aggregateType = TypedAggregate<UpdateCmd, UpdateEvt, CmdErr, Agg>::aggregateType
return from(create, update, created, updated, aggregateType)
}

inline fun <reified CreationCmd : CreationCommand, CreationEvt : CreationEvent, Err : CommandError, reified UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, P, Agg : AggregateWithProjection<UpdateCmd, UpdateEvt, Err, P, Agg>> fromTypedAggregate(
aggregateConstructor: AggregateConstructorWithProjection<CreationCmd, CreationEvt, Err, UpdateCmd, UpdateEvt, P, Agg>,
inline fun <reified CreationCmd : CreationCommand, CreationEvt : CreationEvent, CmdErr : CommandError, reified UpdateCmd : UpdateCommand, UpdateEvt : UpdateEvent, P, Agg : AggregateWithProjection<UpdateCmd, UpdateEvt, CmdErr, P, Agg>> fromTypedAggregate(
aggregateConstructor: AggregateConstructorWithProjection<CreationCmd, CreationEvt, CmdErr, UpdateCmd, UpdateEvt, P, Agg>,
projection: P
): Configuration<CreationCmd, CreationEvt, Err, UpdateCmd, UpdateEvt, TypedAggregate<UpdateCmd, UpdateEvt, Err, *>> {
return fromTypedAggregate<CreationCmd, CreationEvt, Err, UpdateCmd, UpdateEvt, TypedAggregate<UpdateCmd, UpdateEvt, Err, *>>(aggregateConstructor.partial(projection))
): Configuration<CreationCmd, CreationEvt, CmdErr, UpdateCmd, UpdateEvt, TypedAggregate<UpdateCmd, UpdateEvt, CmdErr, *>> {
return fromTypedAggregate<CreationCmd, CreationEvt, CmdErr, UpdateCmd, UpdateEvt, TypedAggregate<UpdateCmd, UpdateEvt, CmdErr, *>>(aggregateConstructor.partial(projection))
}
}

Expand Down

0 comments on commit cac6ce0

Please sign in to comment.