In Lombok, what is the difference between @AllArgsConstructor and @RequiredArgsConstructor?

In short, use @AllArgsConstructor to generate a constructor for all of your class’s fields and use @RequiredArgsConstructor to generate a constructor for all class’s fields that are marked as final. From the documentation, @AllArgsConstructor generates a constructor with 1 parameter for each field in your class. @RequiredArgsConstructor generates a constructor with 1 parameter for each … Read more

Excluding Lombok classes from Sonar coverage report

As mentionned here : https://github.com/jacoco/jacoco/pull/513#issuecomment-293176354 filtering is performed at a time of report generation (creation of html, xml, etc), not at a time of collection of execution information (creation of exec file). So that tools that read execution data directly instead of reading of xml (which is a kind of mistake on their side to … Read more

Lombok not working in eclipse mars

I had the same problem. What helped was: Restart Eclipse Select from top menu Project -> Clean… Clean all projects that use Lombok If it will not help, try again from point 1. (I know it sounds stupid but it worked on my PC on second try.) Also, I’m using Lombok version 1.16.4 (and Eclipse … Read more

Gradle deprecated annotation processor warnings for lombok

Change the lombok dependency type from compile to annotationProcessor, so your dependencies section in your build.gradle file should look like: dependencies { compileOnly(‘org.projectlombok:lombok:1.16.20’) annotationProcessor ‘org.projectlombok:lombok:1.16.20’ // compile ‘org.projectlombok:lombok:1.16.20’ <– this no longer works! // other dependencies… }

How to implements Lombok @Builder for Abstract class

This is possible with lombok 1.18.2 (and above) using the new (experimental) annotation @SuperBuilder. The only restriction is that every class in the hierarchy must have the @SuperBuilder annotation. There is no way around putting @SuperBuilder on all subclasses, because Lombok cannot know all subclasses at compile time. See the lombok documentation for details. Example: … Read more

@JsonIgnore with @Getter Annotation

To put the @JsonIgnore to the generated getter method, you can use onMethod = @__( @JsonIgnore ). This will generate the getter with the specific annotation. For more details check http://projectlombok.org/features/GetterSetter.html @Getter @Setter public class User { private userName; @Getter(onMethod = @__( @JsonIgnore )) @Setter private password; }

Is it possible to make Lombok’s builder public?

@Builder already produces public methods, it’s just the constructor that’s package-private. The reason is that they intend for you to use the static builder() method, which is public, instead of using the constructor directly: Foo foo = Foo.builder() .property(“hello, world”) .build(); If you really, really, really want the constructor to be public (there seems to … Read more