apatrida
06/28/2016, 12:28 PMsalomonbrys
06/28/2016, 12:31 PMfun main(args: Array<String>) {
val test: (Any?) -> Any = { "coucou $it" }
val casted = test as (String) -> String
println(casted("Jayson"))
}
apatrida
06/28/2016, 12:31 PMapatrida
06/28/2016, 12:31 PMsalomonbrys
06/28/2016, 12:31 PMapatrida
06/28/2016, 12:32 PMapatrida
06/28/2016, 12:32 PMapatrida
06/28/2016, 12:32 PMapatrida
06/28/2016, 12:32 PMsalomonbrys
06/28/2016, 12:32 PMType
instead of typeToken
, the only certainty is Any
. A developper using those should be aware of the risk of bad castingapatrida
06/28/2016, 12:33 PMsalomonbrys
06/28/2016, 12:33 PMapatrida
06/28/2016, 12:35 PMbind(type) with ...
I got around using DirectBinder(_bind.tag, overrides)._with(_bind.type, singleton { instance })
salomonbrys
06/28/2016, 12:35 PMapatrida
06/28/2016, 12:35 PMsalomonbrys
06/28/2016, 12:35 PMsalomonbrys
06/28/2016, 12:35 PMapatrida
06/28/2016, 12:35 PMprivate fun addAction(targetConfig: Config) {
actions.add(BindActions {
val asJson = targetConfig.root().render(ConfigRenderOptions.concise().setJson(true))
val instance: T = mapper.readValue(asJson, TypeFactory.defaultInstance().constructType(_bind.type))!!
DirectBinder(_bind.tag, overrides)._with(_bind.type, singleton { instance })
})
}
apatrida
06/28/2016, 12:36 PMapatrida
06/28/2016, 12:36 PMapatrida
06/28/2016, 12:36 PMapatrida
06/28/2016, 12:36 PMsalomonbrys
06/28/2016, 12:37 PMapatrida
06/28/2016, 12:37 PMinstance()
of your config data classesapatrida
06/28/2016, 12:38 PM_context
? or _container
?apatrida
06/28/2016, 12:38 PM_context
issalomonbrys
06/28/2016, 12:38 PMsalomonbrys
06/28/2016, 12:39 PMapatrida
06/28/2016, 12:39 PMapatrida
06/28/2016, 12:40 PM