Class AnnotationBasedNullabilityResolver
- All Implemented Interfaces:
NullabilityResolver
NullabilityResolver reporting a parameter as Nullability.NULLABLE when it carries an annotation
whose simple name is Nullable, regardless of which library declares it.
This covers the runtime-visible variants, whichever position they occupy: jspecify's
org.jspecify.annotations.Nullable in the type-use position, and jakarta.annotation.Nullable or
JSR-305's javax.annotation.Nullable in the declaration position. It cannot cover
org.jetbrains.annotations.Nullable, which uses RetentionPolicy.CLASS retention
and is therefore absent from the class file at runtime.
Registered through this module's META-INF/services file and left unannotated, so it sits at
Priority.NEUTRAL and any resolver that can speak authoritatively for a subset of
parameters, such as one backed by a language's own type information, outranks it.
Never reports Nullability.NON_NULL: an unannotated Java parameter says nothing about whether it accepts
null, so anything other than an explicit Nullable annotation yields Nullability.UNKNOWN.
Marked Internal as it is registered automatically and not meant to be referenced directly.
- Since:
- 5.3.0
- Author:
- Mateusz Nowak
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
AnnotationBasedNullabilityResolver
public AnnotationBasedNullabilityResolver()Constructs the resolver. Invoked by theServiceLoader.
-
-
Method Details
-
resolve
Description copied from interface:NullabilityResolverDetermines the declaredNullabilityof the givenparameter.- Specified by:
resolvein interfaceNullabilityResolver- Parameters:
parameter- the parameter to determine the nullability of- Returns:
- the declared nullability, or
Nullability.UNKNOWNwhen this resolver cannot tell
-