mkarneim / pojobuilder

A Java Code Generator for Pojo Builders
Other
334 stars 44 forks source link

Init to null (instead of nothing) all non-primitive attributes in the generated builder class in order to help spotbugs-maven-plugin to check null safety on @javax.annotation.Nonnull fields or parameters #173

Closed alexandrenavarro closed 2 years ago

alexandrenavarro commented 2 years ago

Init to null (instead of nothing) all non-primitive attributes in the generated builder class in order to help spotbugs-maven-plugin to check null safety on @javax.annotation.Nonnull fields or parameters

Globally, the spotbugs-maven-plugin checks at compile time null safety based on @NonNull / @Nullable annotations and null assignation. For more explanation, you can read this article https://reflectoring.io/spring-boot-null-safety-annotations/ .

Today, the null check on the generated builder is not detected because the attribute of the builder is not set to null, so the maven plugin can not check easily if the call of the constructor of the class in the build method passes some null parameters.

If you are ok with the idea, I can check to make a pull request to add this enhancement.

alexandrenavarro commented 2 years ago

I closed it, I tested it but does not solve my problem.