com.trendyol.kediatr.Container.kt Maven / Gradle / Ivy
package com.trendyol.kediatr
@Suppress("UNCHECKED_CAST")
internal class Container(dependencyProvider: DependencyProvider) : Registrar() {
val commandMap = HashMap, CommandProvider>>()
val queryMap = HashMap, QueryProvider>>()
val notificationMap = HashMap, MutableList>>>()
val pipelineSet = HashSet>()
val commandWithResultMap = HashMap, CommandWithResultProvider<*>>()
init {
registerFor, *>, Query<*>>(dependencyProvider) { key, value ->
queryMap[key] = QueryProvider(dependencyProvider, value as Class>)
}
registerFor, Command>(dependencyProvider) { key, value ->
commandMap[key] = CommandProvider(dependencyProvider, value)
}
registerFor, *>, CommandWithResult<*>>(dependencyProvider) { key, value ->
commandWithResultMap[key] =
CommandWithResultProvider(
dependencyProvider,
value as Class>
)
}
registerFor, Notification>(dependencyProvider) { key, value ->
notificationMap.getOrPut(key) { mutableListOf() }
.add(NotificationProvider(dependencyProvider, value as Class>))
}
registerFor(dependencyProvider) { handler ->
pipelineSet.add(PipelineProvider(dependencyProvider, handler))
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy