I would like to use Lombok's @NonNull
annotation to generate the null-checking code automatically for method parameters while also using FindBugs' @NonNull
to use static analysis tools and generate appropriate warnings whenver the case applies.
As of now, I need to do the following:
public void doSomething (@lombok.NonNull @edu.umd.cs.findbugs.annotations.NonNull Object parameter)
{
// Do something
}
This is quite ugly, so I would like to avoid using this syntax. I read about nested annotations (here and here), but I can't seem to find a way to create my own custom annotation with both NonNull
annotations as nested annotations. Am I trying to do something that cannot work?
Here's my latest attempt:
@Documented
@Retention (RetentionPolicy.CLASS)
@Target (value={ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE})
public @interface MyNonNull
{
public lombok.NonNull lombokNonNull () default @lombok.NonNull;
public edu.umd.cs.findbugs.annotations.NonNull findBugsNonNull () default @edu.umd.cs.findbugs.annotations.NonNull;
}