Polish reactive type support in Conventions
This commit is contained in:
@@ -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.
|
||||
*
|
||||
* <p>As of 5.0 this method supports reactive types:<br>
|
||||
* {@code Mono<com.myapp.Product>} becomes {@code "productMono"}<br>
|
||||
* {@code Flux<com.myapp.MyProduct>} becomes {@code "myProductFlux"}<br>
|
||||
* {@code Observable<com.myapp.MyProduct>} becomes {@code "myProductObservable"}<br>
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* <p>As of 5.0 this method supports reactive types:<br>
|
||||
* {@code Mono<com.myapp.Product>} becomes {@code "productMono"}<br>
|
||||
* {@code Flux<com.myapp.MyProduct>} becomes {@code "myProductFlux"}<br>
|
||||
* {@code Observable<com.myapp.MyProduct>} becomes {@code "myProductObservable"}<br>
|
||||
*
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user