Does the Lombok project work well with Scala?

If I wanted my Scala project to be "compatible" with Java, it makes it practical to call the Scala API from Java code (so non-Scala programmers can also contribute) can Project Lombok be used in Java code? Or both of them do not get along well?

I will be developing in Eclipse using the Scala IDE.

EDIT: I really mean: will the Scala editor in Eclipse see the code generated by Lombok, or only the Java code that I actually printed?

+7
source share
2 answers

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.

+9
source

The scala part of the editor will "perfectly" see the generated code.

Most of what lombok does follows some specification or another, just like scala. Where lombok is rejected, it is canEqual and equal to implementations, which, by the way, is the same as scala generates for case IIRC classes, so even this is compatible :)

DISCLAIMER: I am a major contributor to the lombok project.

+9
source