isn't @NonNull just a syntactic sugar for adding checkNonNull() call as first statement to the function declaration in compile time, or am I mistaken? Just like lombok, it is supposed to generate code that checks null arguments, from what I know.
@Test
public void foo() {
bar(null);
}
void bar(@NonNull String param) {
System.out.println(param);
}
All versions of that annotation let the null right through. I tried with: import lombok.NonNull;
import javax.validation.constraints.NotNull;
import io.micronaut.core.annotation.NonNull;
import org.springframework.lang.NonNull;
import reactor.util.annotation.NonNull; @Test
public void foo() {
final Map<String, Integer> map = new HashMap<>();
map.put("present", 1);
bar(map.get("missing"));
}
void bar(@NotNull Integer param) {
System.out.println(param);
}
"No problems found"