Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

TableView column boolean field detection #560

Closed
LAP2 opened this issue Dec 5, 2017 · 8 comments
Closed

TableView column boolean field detection #560

LAP2 opened this issue Dec 5, 2017 · 8 comments

Comments

@LAP2
Copy link

LAP2 commented Dec 5, 2017

Hi.

I just tried to build table view from java pojo bean with boolean field and default bool getter naming with is
... = tableview(model.list) { column(...) // <= this one is ok cause it getter name with get column("My bool", MyClass::isSomethingBoolean) }
and i got an empty column cause you try to extract field name like this:

@JvmName("pojoColumn") fun <S, T> TableView<S>.column(title: String, getter: KFunction<T>): TableColumn<S, T> { val propName = getter.name.substring(3).let { it.first().toLowerCase() + it.substring(1) } return this.column(title, propName) }

and for "is" getters it wouldn't work fine.
I had avoid it by using field naming column function like
code("My bool", "somethingBoolean") but the work of previous variant isn't look right.

@edvin
Copy link
Owner

edvin commented Dec 5, 2017

This should be easily solved by checking if the getter.name starts with "is" followed by an upper case letter.

@LAP2
Copy link
Author

LAP2 commented Dec 5, 2017

Yep probably, could you just lable this issue like a bug or something?

@edvin edvin added the Type: Bug label Dec 5, 2017
@edvin
Copy link
Owner

edvin commented Dec 5, 2017

Done. I asked if somebody wanted to supply a PR for this in the Slack channel. If nobody has time, I'll add it during the next days :)

@LAP2
Copy link
Author

LAP2 commented Dec 5, 2017

Deal. Many thx.

@edvin
Copy link
Owner

edvin commented Dec 8, 2017

I added the following check to determine the property name:

val startIndex = if (getter.name.startsWith("is") && getter.name[2].isUpperCase()) 2 else 3
val propName = getter.name.substring(startIndex).decapitalize()

@LAP2
Copy link
Author

LAP2 commented Dec 12, 2017

Cool. Thx Edvin. Probably this issue could be closed now.

@LAP2 LAP2 closed this as completed Dec 12, 2017
@edvin
Copy link
Owner

edvin commented Dec 12, 2017

Thanks :) Did it work for you?

@LAP2
Copy link
Author

LAP2 commented Dec 12, 2017

Yep. I had checked it, from snapshot build. It seems to work fine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants