I want to create an annotation that restricts a developer from specifying null as a parameter, which has been annotated with @NoNull
For example, if I create this method:
public void printLine(@NoNull String line) {
System.out.println(line);
}
On a method call, I want an error to appear if the user specifies null for line: printLine(null);
I have been using APT for only a little bit of time, and am wondering how to do this (if possible)?
This is the annotation I have created so far:
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.SOURCE)
public @interface NoNull {}