I'm using annotations library supported by Android. It is useful for checking NullpointerExceptions. But, it also annoying if I checked the variable if it is null.
In this case:
@Nullable
String value;
boolean isValid(String target) {
return (target != null && target.length() > 0);
}
void test() {
if (isValid(value)) {
Log.d("TEST", value);
// Do something.
}
}
In above code, I already checked if 'value' is null, but still got the warning of "It maybe produce NullPointerException".
Is there some annotations that I checked null-type in this function?