Improve @Nullable annotation
This commit makes Spring @Nullable annotation leveraging JSR 305 @TypeQualifierNickname + @Nonnull(when= When.MAYBE) instead of directly using @javax.annotation.Nullable which seems not designed to be used as a meta-annotation. It also removes @TypeQualifierDefault since the purpose of this annotation when applied at method level is to only change return value nullability, not parameters one. Issue: SPR-15540
This commit is contained in:
@@ -6,7 +6,9 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import javax.annotation.meta.TypeQualifierDefault;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.meta.TypeQualifierNickname;
|
||||
import javax.annotation.meta.When;
|
||||
|
||||
/**
|
||||
* Leverage JSR 305 meta-annotations to define the annotated element could be null
|
||||
@@ -20,9 +22,9 @@ import javax.annotation.meta.TypeQualifierDefault;
|
||||
* @see javax.annotation.Nullable
|
||||
*/
|
||||
@Documented
|
||||
@javax.annotation.Nullable
|
||||
@TypeQualifierNickname
|
||||
@Nonnull(when= When.MAYBE)
|
||||
@Target({ElementType.METHOD, ElementType.PARAMETER})
|
||||
@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Nullable {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user