Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @NotNullByDefault annotation #53

Open
Abnaxos opened this issue Jul 2, 2021 · 1 comment
Open

Add @NotNullByDefault annotation #53

Abnaxos opened this issue Jul 2, 2021 · 1 comment

Comments

@Abnaxos
Copy link

Abnaxos commented Jul 2, 2021

It's badly needed. Since years, I have a strict NotNull policy in all of my code, so I simply annotate the whole package. Everyone knows this policy is intact, it's just about telling the IDE as well. If I annotate my NotNull code with NotNull, whenever NotNull is appropriate, my NotNull code basically consists of only NotNull with some occasional actual NotNull code between all the NotNull annotations from time to time. :)

Currently, I fix this by mixing with Eclipse's NonNullByDefault (unfortunately, Eclipse's NonNull and Nullable aren't applicable to methods, fields and parameters (Target({ElementType.TYPE_USE})), so I have to use JetBrains annotations for this).

The new annotation should be applicable to packages and classes, maybe also methods. I personally don't care about using it in types, but other people's mileage may vary. Specifying to what elements exactly it applies (methods, fields and/or parameters, maybe also type use) isn't strictly necessary for me, but probably makes sense. I'd suggest to default to all of them or no default at all.

This would also cover #18.

@J0s3f
Copy link

J0s3f commented Nov 18, 2021

This would also be great in combination with the intellij-annotations-instrumenter-maven-plugin to have fields in specific packages always non-null and others not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants