Polishing

This commit is contained in:
Sam Brannen
2022-11-13 16:01:37 +01:00
parent 1f0a35bacc
commit eb91d21ada
13 changed files with 69 additions and 36 deletions

View File

@@ -33,12 +33,13 @@ import org.springframework.stereotype.Controller;
/**
* {@link ReflectiveProcessor} implementation for {@link Controller} and
* controller-specific annotated methods. On top of registering reflection
* controller-specific annotated methods. In addition to registering reflection
* hints for invoking the annotated method, this implementation handles:
*
* <ul>
* <li>Return types annotated with {@link ResponseBody}.</li>
* <li>Parameters annotated with {@link RequestBody}.</li>
* <li>{@link HttpEntity} return type and parameters.</li>
* <li>Return types annotated with {@link ResponseBody}</li>
* <li>Parameters annotated with {@link RequestBody}</li>
* <li>{@link HttpEntity} return types and parameters</li>
* </ul>
*
* @author Stephane Nicoll
@@ -49,6 +50,7 @@ class ControllerMappingReflectiveProcessor implements ReflectiveProcessor {
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
@Override
public void registerReflectionHints(ReflectionHints hints, AnnotatedElement element) {
if (element instanceof Class<?> type) {
@@ -98,8 +100,8 @@ class ControllerMappingReflectiveProcessor implements ReflectiveProcessor {
@Nullable
private Type getHttpEntityType(MethodParameter parameter) {
MethodParameter nestedParameter = parameter.nested();
return (nestedParameter.getNestedParameterType() == nestedParameter.getParameterType()
? null : nestedParameter.getNestedParameterType());
return (nestedParameter.getNestedParameterType() == nestedParameter.getParameterType() ?
null : nestedParameter.getNestedParameterType());
}
}

View File

@@ -37,4 +37,5 @@ class ExceptionHandlerReflectiveProcessor extends ControllerMappingReflectivePro
}
super.registerReturnTypeHints(hints, returnTypeParameter);
}
}

View File

@@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RequestBody;
/**
* {@link ReflectiveProcessor} implementation for {@link HttpExchange @HttpExchange}
* and annotated methods. On top of registering reflection hints for invoking
* annotated methods. In addition to registering reflection hints for invoking
* the annotated method, this implementation handles reflection-based
* binding for return types and parameters annotated with {@link RequestBody}.
*
@@ -40,6 +40,7 @@ class HttpExchangeReflectiveProcessor implements ReflectiveProcessor {
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
@Override
public void registerReflectionHints(ReflectionHints hints, AnnotatedElement element) {
if (element instanceof Method method) {