cedric
02/24/2016, 2:04 PMclass Db @Inject constructor(val database: Database, @Assisted val tableName: String) {
interface IFactory {
fun create(tableName: String = "ACCOUNTS") : Db
}
}
class A @Inject constructor(val dbFactory: Db.IFactory) {
fun a() {
val db1 = dbFactory.create() // db for "ACCOUNTS"
val db2 = dbFactory.create("USERS") // db for "USERS
}
}
Basically using assisted injection and moving the default parameters in the interface.