jvmMain.it.unibo.tuprolog.solve.SolverExtensionsJvm.kt Maven / Gradle / Ivy
package it.unibo.tuprolog.solve
@Suppress("SwallowedException")
internal actual fun solverFactory(
className: String,
vararg classNames: String,
): SolverFactory {
return sequenceOf(className, *classNames)
.map {
try {
Class.forName(it).kotlin
} catch (e: ClassNotFoundException) {
null
}
}
.filterNotNull()
.map { it.objectInstance }
.filterIsInstance()
.firstOrNull()
?: error("No viable implementation for ${SolverFactory::class.simpleName}")
}
actual fun classicSolverFactory(): SolverFactory = solverFactory(FactoryClassNames.CLASSIC)
actual fun streamsSolverFactory(): SolverFactory = solverFactory(FactoryClassNames.STREAMS)
actual fun problogSolverFactory(): SolverFactory = solverFactory(FactoryClassNames.PROBLOG)
actual fun concurrentSolverFactory(): SolverFactory = solverFactory(FactoryClassNames.CONCURRENT)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy