I am currently working on a Scala application which utilizes Spring-Boot and Swagger to send & receive REST-calls.
Swagger and Spring-Boot are pure Java-projects an
You don't need to write out java.lang.blah every time in
ParamsAsJava(java.lang.Boolean.FALSE, java.lang.Boolean.TRUE)
Just use
ParamsAsJava(false, true)
instead. Autoboxing hasn't gone anywhere.
to get rid of toScala, define an implicit conversion in Params companion object:
object Params {
implicit def params_j2s(p: ParamsAsJava): Params = p.toScala()
}
now you can write:
val test1: Params = ParamsAsJava(true, false)
and, of course, if you don't define this variable in vacuum, but pass it to a method instead, the right type will be inferred automatically, and the object will be converted implicitly.
No need to use parens () in def toScala(), the method has no side effects.