Class AnnotationBasedNullabilityResolver

java.lang.Object
org.axonframework.common.nullability.AnnotationBasedNullabilityResolver
All Implemented Interfaces:
NullabilityResolver

@Internal public class AnnotationBasedNullabilityResolver extends Object implements 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 Details

    • AnnotationBasedNullabilityResolver

      public AnnotationBasedNullabilityResolver()
      Constructs the resolver. Invoked by the ServiceLoader.
  • Method Details