Scoped @NotNull/ @NotNull(class/package) ?


I wonder if it is possible to have some sort of scoped @NotNull inspection.
The problem is that there are not very many pure @NotNull things. Very often
things can be null untill initialization and then never null after that.
Therefore only in certain stage of its life cycle (may be within certain
class) it can be null (e.g inside of factory method creating and populating
a bean) while it is not null for the rest of its life. Often we develop an
APIs where certain things are not null for API user but can be null inside
API. I wish we could annotate those things as not null for API user sace. If
it only were possible to take advantage of this knowledge it would allowed
us to use null inspections much wider.

How about allowing to declare @NotNull(class/package)
@Nullable(class/package) to give an inspection some scope

Any ideas?

Thank you


Please sign in to leave a comment.