https://kotlinlang.org logo
Title
n

Nikky

09/22/2018, 7:47 PM
so extract that somwhere and save it alongside your tablecells
v

ValV

09/22/2018, 9:10 PM
Could not make it work with
reified
, 'cause
typeTokenOf()
from the example above takes a class name, which I do not know e.g.
val myType = typeTokenOf<String>()
, I have only an object of some type
myColumn
, and cannot be passed into the function as
val myType = typeTokenOf<myColumn>() // Error
But I did in another way:
fun <S, T> translate(c: TableColumn<S, T>): ObjectProperty<T> = SimpleObjectProperty<T>(c.getCellData(null))
It works, but what's going on under the hood -- I don't know. It's kinda black magic. I don't understand why
SimpleObjectProperty<T>(c.getCellData(null))
gives desired result
Perhaps, I explained the problem not quite correct initially -- I had to get a type from an object. Also, if JVM erases types, I do not understand, why
fun translate
works
n

Nikky

09/22/2018, 11:01 PM
on in that case you can get the KClass from a Any reference, it will be type erased however, so if it was a List of any type.. all you get is a
List<*>