I need to access a large set of Java interfaces from Scala. These interfaces have methods that might return Null, and I want to convert them to Option[T]
I found other answers that describe Option.apply()
like these
How to implicitly wrap a value that can be null or an array into an Scala Option
However, this requires that for each Java interface, I manually create a Scala wrapper. Like this...
class ScalaFoo extends JavaFoo {
def bar = Option(super.bar)
}
That seems messy, hard to maintain, and prone to error. I don't want all that extra code that does nothing, and I want to automatically wrap all my Java interfaces, so that if one changes, the wrapper also changes.
Surely, there is a way to do this with implicits, isn't there?