Some frameworks (JSR 303, JetBrains) use the latter name.
It would be nice if we didn't have to add both @NotNull and @NonNull.
+1
+1 for JSR 303, that is a standard annotation.
I came here intending to make that very same feature request.
I am not convinced this makes sense.
@NotNull is a validation annotation, whereas @Nonnull is a documentation annotation.
Or to elaborate for clarity:
@NotNull means that if that field is null, then validation should fail.@Nonnull or @Nullable is supposed to be read by users of that API (developers) as intended use.Another reason that this doesn't make sense: adding @NotNull on getters/setters, will not silence Findbugs.
What would make sense, in my opinion, is an option for Lombok to generate @Nonnull or @Nullable in the getters/setters, based on the existence of @NotNull on a field.
Would be ideal if this was a global option, and not an annotation parameter. Coding standards are usually fixed for a specific project.
An annotation parameter could be used to override the global option, for exceptional cases.
@Kidlike
While javax.validation.annotations.NotNull does indeed mean that, org.jetbrains.annotations.NotNull has the same semantics as javax.annotation.Nonnull.
@OrangeDog
(obviously) I didn't realize the context was org.jetbrains and not javax.validation.
In this case then, I don't have a strong opinion. It's a nice to have, but not that critical.
I'm gonna move my suggestion to a new ticket :)
Well it's both. It works by the simple name of the annotation right now doesn't it, rather than the exact class?
Some frameworks (JSR 303, JetBrains) use the latter name.
What specifically I would like right now is I put javax.validation.annotations.NotNull on a field and the generated constructors/setters include some null checks.
I would assume that it works by reading the #canonicalName and not #simpleName.
If it actually works by reading the #simpleName, then I would argue that @NotNull should imply javax.validation and not org.jetbrains.
Most helpful comment
I am not convinced this makes sense.
@NotNullis a validation annotation, whereas@Nonnullis a documentation annotation.Or to elaborate for clarity:
@NotNullmeans that if that field is null, then validation should fail.@Nonnullor@Nullableis supposed to be read by users of that API (developers) as intended use.Another reason that this doesn't make sense: adding
@NotNullon getters/setters, will not silence Findbugs.What would make sense, in my opinion, is an option for Lombok to generate
@Nonnullor@Nullablein the getters/setters, based on the existence of@NotNullon a field.Would be ideal if this was a global option, and not an annotation parameter. Coding standards are usually fixed for a specific project.
An annotation parameter could be used to override the global option, for exceptional cases.