A NonNullByDefault annotation makes selected types non-null unless a declaration explicitly overrides the default. It can apply to a class, interface, or package, reducing repetitive nullity annotations. section 5.1.3
Defaulting parameters and return values
@NonNullByDefault({DefaultLocation.PARAMETER, DefaultLocation.RETURN_TYPE}) public interface MyInterface { String processString(String input); } Here, processString() is specified to reject a null input and never return null. Use an explicit nullable annotation when an exception to the default is part of the API. section 5.1.3
Treat the annotation as an API contract: it simplifies nullity specification, while static analysis can check calls against the declared defaults and expose contradictory null assumptions. section 5.1.3
