diff --git a/spring-core/src/main/java/org/springframework/core/Conventions.java b/spring-core/src/main/java/org/springframework/core/Conventions.java index a1b3c62315..1fbeeae686 100644 --- a/spring-core/src/main/java/org/springframework/core/Conventions.java +++ b/spring-core/src/main/java/org/springframework/core/Conventions.java @@ -36,6 +36,7 @@ import org.springframework.util.ClassUtils; * * @author Rob Harrop * @author Juergen Hoeller + * @author Rossen Stoyanchev * @since 2.0 */ public abstract class Conventions { @@ -108,6 +109,12 @@ public abstract class Conventions { /** * Determine the conventional variable name for the given parameter taking * the generic collection type, if any, into account. + * + *
As of 5.0 this method supports reactive types: As of 5.0 this method supports reactive types:
+ * {@code Mono
+ * {@code Flux
+ * {@code Observable
+ *
* @param parameter the method or constructor parameter
* @return the generated variable name
*/
@@ -132,10 +139,12 @@ public abstract class Conventions {
else {
valueClass = parameter.getParameterType();
- ReactiveAdapter adapter = reactiveAdapterRegistry.getAdapter(valueClass);
- if (adapter != null && !adapter.getDescriptor().isNoValue()) {
- reactiveSuffix = ClassUtils.getShortName(valueClass);
- valueClass = parameter.nested().getNestedParameterType();
+ if (reactiveAdapterRegistry.hasAdapters()) {
+ ReactiveAdapter adapter = reactiveAdapterRegistry.getAdapter(valueClass);
+ if (adapter != null && !adapter.getDescriptor().isNoValue()) {
+ reactiveSuffix = ClassUtils.getShortName(valueClass);
+ valueClass = parameter.nested().getNestedParameterType();
+ }
}
}
@@ -171,6 +180,12 @@ public abstract class Conventions {
* method, taking the generic collection type, if any, into account, falling
* back on the given return value if the method declaration is not specific
* enough, e.g. {@code Object} return type or untyped collection.
+ *
+ *
+ * {@code Mono
+ * {@code Flux
+ * {@code Observable
+ *
* @param method the method to generate a variable name for
* @param resolvedType the resolved return type of the method
* @param value the return value (may be {@code null} if not available)
@@ -215,10 +230,12 @@ public abstract class Conventions {
else {
valueClass = resolvedType;
- ReactiveAdapter adapter = reactiveAdapterRegistry.getAdapter(valueClass);
- if (adapter != null && !adapter.getDescriptor().isNoValue()) {
- reactiveSuffix = ClassUtils.getShortName(valueClass);
- valueClass = ResolvableType.forMethodReturnType(method).getGeneric(0).resolve();
+ if (reactiveAdapterRegistry.hasAdapters()) {
+ ReactiveAdapter adapter = reactiveAdapterRegistry.getAdapter(valueClass);
+ if (adapter != null && !adapter.getDescriptor().isNoValue()) {
+ reactiveSuffix = ClassUtils.getShortName(valueClass);
+ valueClass = ResolvableType.forMethodReturnType(method).getGeneric(0).resolve();
+ }
}
}