In the version of lombok-pg I'm using (0.11.3), Builder will allow fields which are marked @NonNull to be initialized to null, as demonstrated below. If possible, I think Builder should do a runtime check to ensure that the object passed in is indeed not null, just like @Setter does.
import lombok.Builder;
import lombok.NonNull;
import lombok.Getter;
@Builder
@Getter
class Foo {
@NonNull private final String bar;
public static void main(String[] args){
Foo f = Foo.foo().bar(null).build(); // Does *not* throw NullPointerException
System.out.println(f.getBar()); // Prints null.
}
}
I am aware of a similar-sounding issue, https://github.com/peichhorn/lombok-pg/issues/54. However that issue seems to indicate that fields marked @NonNull should be mandatory fields (just like final fields), but does not mention that the Builder should actually do the null check.
In the version of lombok-pg I'm using (0.11.3),
Builder
will allow fields which are marked@NonNull
to be initialized tonull
, as demonstrated below. If possible, I thinkBuilder
should do a runtime check to ensure that the object passed in is indeed not null, just like@Setter
does.I am aware of a similar-sounding issue, https://github.com/peichhorn/lombok-pg/issues/54. However that issue seems to indicate that fields marked
@NonNull
should be mandatory fields (just likefinal
fields), but does not mention that theBuilder
should actually do the null check.