@Documented @Retention(value=RUNTIME) @Target(value={METHOD,CONSTRUCTOR}) public @interface RequiresNonNull
For example:
@Nullable Object field1; @Nullable Object field2; @RequiresNonNull("field1") void method1() { field1.toString(); // OK, field1 is known to be non-null field2.toString(); // error, might throw NullPointerException } void method2() { field1 = new Object(); method1(); // OK, satisfies method precondition field1 = null; method1(); // error, does not satisfy method precondition }
public abstract String[] value
NonNull
.