dimsuz
01/09/2019, 4:04 PMval
?
I use DI framework and it finds primitive boolean
here:
class MyPresenter @Inject constructor(val field: Boolean)
and fails to generate injector.
One way is to use val field: java.lang.Boolean
, but it feels a bit dirty and generates a warninghudsonb
01/09/2019, 6:29 PMval field: Boolean?
work?karelpeeters
01/09/2019, 7:17 PMimport java.lang.Boolean as BBoolean
and then use that.Dico
01/10/2019, 2:10 AMArtem Golovko
01/10/2019, 6:34 AM@Configuration
class AppConfig(
@Value("\${my-app.boolean}") private val bool: Boolean)
Or you can use nullable var
@Configuration
class AppConfif() {
@Value("\${my-app.boolean}")
var: Boolean? = null
}
Maybe in your case you could use nullable Boolean?
class MyPresenter @Inject constructor(val field: Boolean?)
Anyway it should be supported by DI framework. If framework doesn't support constructor injection it may be problem in kotlin with primitives, because in Kotlin all primitives is not null unlike Javadimsuz
01/10/2019, 12:11 PM