A method that is marked with annotations such as @Nonnull
should not return explicit null values.
Returning null when the method is explicitly marked as non-null is a bad practice, since it defeats the purpose of the method being annotated in the first place.
@Nonnull
String someMethod() {
// ...
if (someCondition) {
return null; // Not right!
}
// ...
return value;
}
Avoid returning null if the method is marked as not returning null.