@Nullable / @NonNull
See original GitHub issueI use these annotations a LOT and I don’t think you use them. Would you consider adding them?
For example, Box#put
supports null collections but doesn’t say so:
public void put(Collection<T> entities) {
if(entities != null && !entities.isEmpty()) { // yay!
Cursor cursor = getWriter();
try {
Iterator i = entities.iterator();
while(i.hasNext()) {
cursor.put(i.next());
}
commitWriter(cursor);
} finally {
releaseWriter(cursor);
}
}
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:19 (9 by maintainers)
Top Results From Across the Web
@Nullable and @NotNull | IntelliJ IDEA Documentation
@Nullable and @NotNull annotations let you check nullability of a variable, parameter, or return value. They help you control contracts ...
Read more >Nullable & NonNull - Medium
The @NonNull/@Nullable annotation can put in front of functions as well to indicate the return value nullability. @NonNull public A getA() {
Read more >java - How to use @Nullable and @Nonnull annotations more ...
@Nonnull annotation just emphasises that null-verification of the argument is on your side (you have to guarantee that you pass non-null value). It...
Read more >Spring Null-Safety Annotations - Baeldung
The @Nullable Annotation. The @NonNullFields annotation is generally preferable to @NonNull as it helps reduce boilerplate.
Read more >@NonNull - Project Lombok
You can use @NonNull on a record component, or a parameter of a method or constructor. This will cause to lombok generate a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I tried to use compileOnly for jsr305. This seems to break kapt rather quickly. Also, annotations are already used in generated code / super classes of generated code. Thus, it seems simpler to stick with a compile dependency. Added a troubleshooting entry in the FAQ for this.
@BenoitDuffez I’m just finishing this, so no need to reopen. Will ship with next release.