What is the difference between following two code snippets.
public Integer getId(@Nonnull SomeObject obj){
// do some stuff
return id;
}
public In
The difference is that in the first case it's a hint for a compiler and IDE that the argument should not be null, so when you write getId(null)you'll get an error. But someone may pass null value in runtime.
As for the second case, it's a kind of defensive programming, when you fail-fast with a precondition that the argument should not be null.