So I just drilled into my colleague that he should not be doing as the title states. But I fought so strongly for my stance that I want to make sure that I am actually right (the worst thing I want to do is enforce an incorrect opinion on someone else).
So basically I'm trying to verify that the following is indeed bad practice:
public void methodA(@Nullable String value) {
if (value == null) throw new IllegalArgumentException();
...
}
His argument was that @Nullable simply states that you can pass a null in here, but it doesn't guarantee that the result of doing so will be "nice".
Whereas my argument is that doing so breaks the contract that @Nullable implies that a null value will be properly handled and not treated as exceptional.
The problem is I can't find any documentation actually verifying my claim.
Ultimately I was able to convince him of my stance, but now I'm concerned that perhaps I was wrong.
Ah, I am missing some context here. So we are using @NonNullApi from Spring, which by default puts a @Nonnull on all the params. So if you want to support a null param, you need to override this with a @Nullable annotation.