I'm not sure what you're asking, since Scala and Java interact at the bytecode level, it doesn't care where the bytecode comes from. Therefore, I believe that your Java code that uses the Lombok annotation can still be called from a Scala program.
And if you ask if these annotations can provide Lombok in Scala code, I see no reason, because most of these functions are provided by Scala itsef.
For example, a class with @Data
might be a case class
in Scala.
case class Data(name: String, value: Int)
And you can access it in Java code, like a regular class.
Data d1 = new Data("someData", 1); // Using constructor Data d2 = Data.apply("someData", 1); // Or using factory
And Data
will have all the wonderful toString
, equals
, hashcode
.... etc.
Brian hsu
source share