Package org.springframework.core
Enum Class Nullness
- All Implemented Interfaces:
Serializable
,Comparable<Nullness>
,Constable
Constants that indicate nullness, as well as related utility methods.
Nullness applies to type usage, a field, a method return type, or a parameter.
JSpecify annotations are
fully supported, as well as
Kotlin null safety,
@Nullable
annotations regardless of their package, and Java primitive
types.
JSR-305 annotations as well as Spring null safety annotations in the
org.springframework.lang
package such as @NonNullApi
,
@NonNullFields
, and @NonNull
are not supported by this API.
However, @Nullable
is supported via the package-less check. Migrating
to JSpecify is recommended.
- Since:
- 7.0
- Author:
- Sebastien Deleuze
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionWill not include null (Kotlin default and JSpecify@NullMarked
code).Can include null (typically specified with a@Nullable
annotation).Unspecified nullness (Java default for non-primitive types and JSpecify@NullUnmarked
code). -
Method Summary
Modifier and TypeMethodDescriptionstatic Nullness
Return the nullness of the given field.static Nullness
forMethodParameter
(MethodParameter methodParameter) Return the nullness of the given method parameter.static Nullness
forMethodReturnType
(Method method) Return the nullness of the return type for the given method.static Nullness
forParameter
(Parameter parameter) Return the nullness of the given parameter.static Nullness
Returns the enum constant of this class with the specified name.static Nullness[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
UNSPECIFIED
Unspecified nullness (Java default for non-primitive types and JSpecify@NullUnmarked
code). -
NULLABLE
Can include null (typically specified with a@Nullable
annotation). -
NON_NULL
Will not include null (Kotlin default and JSpecify@NullMarked
code).
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
forMethodReturnType
Return the nullness of the return type for the given method.- Parameters:
method
- the source for the method return type- Returns:
- the corresponding nullness
-
forParameter
Return the nullness of the given parameter.- Parameters:
parameter
- the parameter descriptor- Returns:
- the corresponding nullness
-
forMethodParameter
Return the nullness of the given method parameter.- Parameters:
methodParameter
- the method parameter descriptor- Returns:
- the corresponding nullness
-
forField
Return the nullness of the given field.- Parameters:
field
- the field descriptor- Returns:
- the corresponding nullness
-