Shorten returnValueType name in HandlerResult
This commit is contained in:
@@ -37,7 +37,7 @@ public class HandlerResult {
|
||||
|
||||
private final Optional<Object> returnValue;
|
||||
|
||||
private final ResolvableType returnValueType;
|
||||
private final ResolvableType returnType;
|
||||
|
||||
private final ModelMap model;
|
||||
|
||||
@@ -48,25 +48,25 @@ public class HandlerResult {
|
||||
* Create a new {@code HandlerResult}.
|
||||
* @param handler the handler that handled the request
|
||||
* @param returnValue the return value from the handler possibly {@code null}
|
||||
* @param returnValueType the return value type
|
||||
* @param returnType the return value type
|
||||
*/
|
||||
public HandlerResult(Object handler, Object returnValue, ResolvableType returnValueType) {
|
||||
this(handler, returnValue, returnValueType, null);
|
||||
public HandlerResult(Object handler, Object returnValue, ResolvableType returnType) {
|
||||
this(handler, returnValue, returnType, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code HandlerResult}.
|
||||
* @param handler the handler that handled the request
|
||||
* @param returnValue the return value from the handler possibly {@code null}
|
||||
* @param returnValueType the return value type
|
||||
* @param returnType the return value type
|
||||
* @param model the model used for request handling
|
||||
*/
|
||||
public HandlerResult(Object handler, Object returnValue, ResolvableType returnValueType, ModelMap model) {
|
||||
public HandlerResult(Object handler, Object returnValue, ResolvableType returnType, ModelMap model) {
|
||||
Assert.notNull(handler, "'handler' is required");
|
||||
Assert.notNull(returnValueType, "'returnValueType' is required");
|
||||
Assert.notNull(returnType, "'returnType' is required");
|
||||
this.handler = handler;
|
||||
this.returnValue = Optional.ofNullable(returnValue);
|
||||
this.returnValueType = returnValueType;
|
||||
this.returnType = returnType;
|
||||
this.model = (model != null ? model : new ExtendedModelMap());
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ public class HandlerResult {
|
||||
/**
|
||||
* Return the type of the value returned from the handler.
|
||||
*/
|
||||
public ResolvableType getReturnValueType() {
|
||||
return this.returnValueType;
|
||||
public ResolvableType getReturnType() {
|
||||
return this.returnType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.reactive.result;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -80,13 +79,13 @@ public class SimpleResultHandler implements Ordered, HandlerResultHandler {
|
||||
|
||||
@Override
|
||||
public boolean supports(HandlerResult result) {
|
||||
ResolvableType type = result.getReturnValueType();
|
||||
ResolvableType type = result.getReturnType();
|
||||
if (Void.TYPE.equals(type.getRawClass())) {
|
||||
return true;
|
||||
}
|
||||
if (getConversionService().canConvert(type.getRawClass(), Mono.class) ||
|
||||
getConversionService().canConvert(type.getRawClass(), Flux.class)) {
|
||||
Class<?> clazz = result.getReturnValueType().getGeneric(0).getRawClass();
|
||||
Class<?> clazz = result.getReturnType().getGeneric(0).getRawClass();
|
||||
return Void.class.equals(clazz);
|
||||
}
|
||||
return false;
|
||||
@@ -105,7 +104,7 @@ public class SimpleResultHandler implements Ordered, HandlerResultHandler {
|
||||
return (Mono<Void>) returnValue;
|
||||
}
|
||||
|
||||
ResolvableType returnType = result.getReturnValueType();
|
||||
ResolvableType returnType = result.getReturnType();
|
||||
if (getConversionService().canConvert(returnType.getRawClass(), Mono.class)) {
|
||||
return this.conversionService.convert(returnValue, Mono.class);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ResponseBodyResultHandler extends AbstractMessageConverterResultHan
|
||||
|
||||
@Override
|
||||
public boolean supports(HandlerResult result) {
|
||||
ResolvableType returnType = result.getReturnValueType();
|
||||
ResolvableType returnType = result.getReturnType();
|
||||
if (returnType.getSource() instanceof MethodParameter) {
|
||||
MethodParameter parameter = (MethodParameter) returnType.getSource();
|
||||
if (hasResponseBodyAnnotation(parameter) && !isHttpEntityType(returnType)) {
|
||||
@@ -118,7 +118,7 @@ public class ResponseBodyResultHandler extends AbstractMessageConverterResultHan
|
||||
@Override
|
||||
public Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result) {
|
||||
Object body = result.getReturnValue().orElse(null);
|
||||
ResolvableType bodyType = result.getReturnValueType();
|
||||
ResolvableType bodyType = result.getReturnType();
|
||||
return writeBody(exchange, body, bodyType);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,12 +78,12 @@ public class ResponseEntityResultHandler extends AbstractMessageConverterResultH
|
||||
|
||||
@Override
|
||||
public boolean supports(HandlerResult result) {
|
||||
ResolvableType returnType = result.getReturnValueType();
|
||||
ResolvableType returnType = result.getReturnType();
|
||||
if (isSupportedType(returnType)) {
|
||||
return true;
|
||||
}
|
||||
else if (getConversionService().canConvert(returnType.getRawClass(), Mono.class)) {
|
||||
ResolvableType genericType = result.getReturnValueType().getGeneric(0);
|
||||
ResolvableType genericType = result.getReturnType().getGeneric(0);
|
||||
return isSupportedType(genericType);
|
||||
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class ResponseEntityResultHandler extends AbstractMessageConverterResultH
|
||||
@Override
|
||||
public Mono<Void> handleResult(ServerWebExchange exchange, HandlerResult result) {
|
||||
|
||||
ResolvableType returnType = result.getReturnValueType();
|
||||
ResolvableType returnType = result.getReturnType();
|
||||
Mono<?> returnValueMono;
|
||||
ResolvableType bodyType;
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ public class ViewResolutionResultHandler extends ContentNegotiatingResultHandler
|
||||
|
||||
@Override
|
||||
public boolean supports(HandlerResult result) {
|
||||
Class<?> clazz = result.getReturnValueType().getRawClass();
|
||||
Class<?> clazz = result.getReturnType().getRawClass();
|
||||
if (hasModelAttributeAnnotation(result)) {
|
||||
return true;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class ViewResolutionResultHandler extends ContentNegotiatingResultHandler
|
||||
return true;
|
||||
}
|
||||
if (getConversionService().canConvert(clazz, Mono.class)) {
|
||||
clazz = result.getReturnValueType().getGeneric(0).getRawClass();
|
||||
clazz = result.getReturnType().getGeneric(0).getRawClass();
|
||||
return isSupportedType(clazz);
|
||||
}
|
||||
return false;
|
||||
@@ -171,7 +171,7 @@ public class ViewResolutionResultHandler extends ContentNegotiatingResultHandler
|
||||
|
||||
Mono<Object> valueMono;
|
||||
ResolvableType elementType;
|
||||
ResolvableType returnType = result.getReturnValueType();
|
||||
ResolvableType returnType = result.getReturnType();
|
||||
|
||||
if (getConversionService().canConvert(returnType.getRawClass(), Mono.class)) {
|
||||
Optional<Object> optionalValue = result.getReturnValue();
|
||||
|
||||
Reference in New Issue
Block a user