In my Spring project there is a service
public Pageable<MyObject>findAccount(String accountExternalId){
if (accountExternalId== null) {
throw new ProjectException("Missing account");
}
...
}
So when I java 5 arguments I have to make 5 ifs in which to check for null input objects. Not to do this I want to use javax.annotation.Nonnull
and javax.annotation.CheckForNull
and to do something like.
public Pageable<MyObject>findAccount(@Nonnull String accountExternalId){
...
}
and use findbugs
<groupId>
com.google.code.findbugs
</groupId>
<artifactId>
findbugs
</artifactId>
So I am wondering how this annotation prevent users not to pass Null values? Or it only annotate that you have not to pass null and is only with informational purpose?