All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cultureamp.eventsourcing.Route.kt Maven / Gradle / Ivy

The newest version!
package com.cultureamp.eventsourcing

import kotlin.reflect.KClass

data class Route(
    val creationCommandClass: KClass,
    val updateCommandClass: KClass,
    val executionContextClass: KClass,
    val aggregateConstructor: AggregateConstructor
) {
    companion object {
        inline fun  from(
            aggregateConstructor: AggregateConstructor
        ): Route = Route(CC::class, UC::class, M::class, aggregateConstructor)

        inline fun  from(
            simpleAggregateConstructor: SimpleAggregateConstructor
        ): Route {
            return from(AggregateConstructor.from>(simpleAggregateConstructor))
        }

        @JvmName("fromCreationCommandReturningMultipleEvents")
        inline fun  from(
            noinline create: (CC, M) -> Either>>,
            noinline update: A.(UC, M) -> Either>,
            noinline created: (CE) -> A,
            noinline updated: A.(UE) -> A = { _ -> this },
            noinline aggregateType: () -> String = { A::class.simpleName!! }
        ): Route = from(AggregateConstructor.from(create, update, created, updated, aggregateType))

        inline fun  from(
            noinline create: (CC, M) -> Either,
            noinline update: A.(UC, M) -> Either>,
            noinline created: (CE) -> A,
            noinline updated: A.(UE) -> A = { _ -> this },
            noinline aggregateType: () -> String = { A::class.simpleName!! }
        ): Route = from(AggregateConstructor.from(create, update, created, updated, aggregateType))

        inline fun  from(
            noinline create: (CC) -> Either,
            noinline update: A.(UC) -> Either>,
            noinline created: (CE) -> A,
            noinline updated: A.(UE) -> A = { _ -> this },
            noinline aggregateType: () -> String = { A::class.simpleName!! }
        ): Route = from(AggregateConstructor.from(create, update, created, updated, aggregateType))

        inline fun  fromStateless(
            noinline create: (CC, M) -> Either,
            noinline update: (UC, M) -> Either>,
            instance: A,
            noinline aggregateType: () -> String = { A::class.simpleName!! }
        ): Route = from(AggregateConstructor.fromStateless(create, update, instance, aggregateType))
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy