A custom check for Checkstyle that ensures that field, method parameter and return types are annotated with annotations specified in the check's configuration.
At the moment, check doesn't recognize annotations specified at the class level.
CTOR_DEFfor checking constructor parameter typesMETHOD_DEFfor checking method parameter and return typesVARIABLE_DEFfor checking non-local field types
| Name | Type | Default | Description |
|---|---|---|---|
tokens |
String[] |
CTOR_DEF, METHOD_DEF, VARIABLE_DEF |
Any combination of tokens above |
nonnullClassNames |
String[] |
Not specified, mandatory | Fully qualified class names that should be treated as "Nonnull" annotations. |
nullableClassNames |
String[] |
Not specified, mandatory | Fully qualified class names that should be treated as "Nullable" annotations. |
checkLocalVariables |
boolean |
true |
Whether local variables should be checked as well |
<module name="NullabilityAnnotationsCheck">
<property name="tokens" value="CTOR_DEF, METHOD_DEF, VARIABLE_DEF"/>
<property name="nonnullClassNames" value="org.jspecify.annotations.NonNull"/>
<property name="nullableClassNames" value="org.jspecify.annotations.Nullable"/>
<property name="checkLocalVariables" value="false"/>
</module>