-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GH-10083 Add Nullability to the mapping package #10382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* Provides classes related to mapping to/from message headers. | ||
*/ | ||
@org.springframework.lang.NonNullApi | ||
@org.jspecify.annotations.NullMarked | ||
package org.springframework.integration.mapping; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ | |
|
||
import org.springframework.core.ResolvableType; | ||
import org.springframework.core.convert.TypeDescriptor; | ||
import org.springframework.lang.Contract; | ||
import org.springframework.util.Assert; | ||
import org.springframework.util.ClassUtils; | ||
|
||
/** | ||
|
@@ -32,6 +34,7 @@ | |
* | ||
* @author Artem Bilan | ||
* @author Gary Russell | ||
* @author Glenn Renfro | ||
* | ||
* @since 3.0 | ||
*/ | ||
|
@@ -67,18 +70,18 @@ private JsonHeaders() { | |
* @return the {@link ResolvableType} based on provided class components | ||
* @since 5.2.4 | ||
*/ | ||
public static ResolvableType buildResolvableType(ClassLoader classLoader, Object targetClassValue, | ||
public static ResolvableType buildResolvableType(@Nullable ClassLoader classLoader, Object targetClassValue, | ||
@Nullable Object contentClassValue, @Nullable Object keyClassValue) { | ||
|
||
Class<?> targetClass = getClassForValue(classLoader, targetClassValue); | ||
Class<?> keyClass = getClassForValue(classLoader, keyClassValue); | ||
Class<?> contentClass = getClassForValue(classLoader, contentClassValue); | ||
|
||
Assert.notNull(targetClass, "targetClass must not be null"); | ||
return buildResolvableType(targetClass, contentClass, keyClass); | ||
} | ||
|
||
@Nullable | ||
|
||
private static Class<?> getClassForValue(ClassLoader classLoader, @Nullable Object classValue) { | ||
private static Class<?> getClassForValue(@Nullable ClassLoader classLoader, @Nullable Object classValue) { | ||
if (classValue instanceof Class<?>) { | ||
return (Class<?>) classValue; | ||
} | ||
|
@@ -103,9 +106,9 @@ else if (classValue != null) { | |
* @return the {@link ResolvableType} based on provided class components | ||
* @since 5.2.4 | ||
*/ | ||
@Contract("_, !null, _ -> !null; _, _, !null -> !null") | ||
|
||
public static ResolvableType buildResolvableType(Class<?> targetClass, @Nullable Class<?> contentClass, | ||
@Nullable Class<?> keyClass) { | ||
|
||
if (keyClass != null) { | ||
return TypeDescriptor | ||
.map(targetClass, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/** | ||
* Support classes for mapping. | ||
*/ | ||
@org.jspecify.annotations.NullMarked | ||
package org.springframework.integration.mapping.support; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you fix
getClassForValue()
with the@Contract
, this is not necessary.