I would like to reduce redundant and verbose null checks in Java , but I understand Java does not have a standard @NotNull annotation where as c# has contracts that can be used, such as
Contract.Requires( x != null );
I might be missing something, but couldn't I just code my own?
public class Contract {
public static void requireNotNull(Object object) {
if ( object == null )
throw new IllegalArgumentException("Contract forbids null");
}
}
Is this missing any of the benefits of @NotNull or Contracts?