I'm getting started with using Scala on Android and a lot of the accessor methods are standard JavaBeans accessors, e.g. setTitle(...)
and getTitle()
. It's a lot nicer to use the title_=
and title
methods in scala, so I can write code like:
button.title = "Foo"
Is there any way to automatically map these from JavaBeans-style accessors, maybe using the Dynamic
trait?
I think Dynamic would work, except it is not presently supported with syntactic sugar. Also, it would return AnyRef
since there's no way to pass what the expected return type is.
Of course, you can simply use pimp my library to add appropriate Scala-style getters and setters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With