edvin / tornadofx2

TornadoFX 2.0
Apache License 2.0
154 stars 40 forks source link

TableColumn<T, S?>.converter function doesn't accept non-null-typed columns #46

Open aleksandar-stefanovic opened 2 years ago

aleksandar-stefanovic commented 2 years ago

The code at question is at TableView.kt, around line ~148:

fun <T, S> TableColumn<T, S?>.converter(converter: StringConverter<in S>): TableColumn<T, S?> = apply {
    cellFormat(FX.defaultScope) { text = converter.toString(it) }
}

It requires that the S type parameter is null, so the following code doesn't work:

column("Column name", MyObject::myNonNullProperty).converter(MyCustomTypeConverter)

The fix would be to remove question marks from the S type parameter, so that it can resolve to both null and non-null types, i.e. it doesn't break the API, just makes it available, in addition, to non-null types.