From 3e74476c11713ad983bb47abaa705e465baff346 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 1 Jun 2015 09:48:06 -0400 Subject: [PATCH] Polish --- .../RequestMappingHandlerMapping.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java index 7025f3c88a..2149558a2b 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMapping.java @@ -200,6 +200,22 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi return info; } + /** + * Delegates to {@link #createRequestMappingInfo(RequestMapping, RequestCondition)}, + * supplying the appropriate custom {@link RequestCondition} depending on whether + * the supplied {@code annotatedElement} is a class or method. + * + * @see #getCustomTypeCondition(Class) + * @see #getCustomMethodCondition(Method) + */ + private RequestMappingInfo createRequestMappingInfo(AnnotatedElement element) { + RequestMapping requestMapping = AnnotatedElementUtils.findAnnotation(element, RequestMapping.class); + RequestCondition condition = (element instanceof Class ? + getCustomTypeCondition((Class) element) : + getCustomMethodCondition((Method) element)); + return (requestMapping != null ? createRequestMappingInfo(requestMapping, condition) : null); + } + /** * Provide a custom type-level request condition. * The custom {@link RequestCondition} can be of any type so long as the @@ -211,6 +227,7 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi * @param handlerType the handler type for which to create the condition * @return the condition, or {@code null} */ + @SuppressWarnings("unused") protected RequestCondition getCustomTypeCondition(Class handlerType) { return null; } @@ -226,25 +243,11 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi * @param method the handler method for which to create the condition * @return the condition, or {@code null} */ + @SuppressWarnings("unused") protected RequestCondition getCustomMethodCondition(Method method) { return null; } - /** - * Delegates to {@link #createRequestMappingInfo(RequestMapping, RequestCondition)}, - * supplying the appropriate custom {@link RequestCondition} depending on whether - * the supplied {@code annotatedElement} is a class or method. - * - * @see #getCustomTypeCondition(Class) - * @see #getCustomMethodCondition(Method) - */ - private RequestMappingInfo createRequestMappingInfo(AnnotatedElement annotatedElement) { - RequestMapping requestMapping = AnnotatedElementUtils.findAnnotation(annotatedElement, RequestMapping.class); - RequestCondition customCondition = ((annotatedElement instanceof Class) ? getCustomTypeCondition((Class) annotatedElement) - : getCustomMethodCondition((Method) annotatedElement)); - return ((requestMapping != null) ? createRequestMappingInfo(requestMapping, customCondition) : null); - } - /** * Create a {@link RequestMappingInfo} from the supplied * {@link RequestMapping @RequestMapping} annotation, which is either @@ -254,7 +257,8 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi protected RequestMappingInfo createRequestMappingInfo(RequestMapping requestMapping, RequestCondition customCondition) { - return RequestMappingInfo.paths(resolveEmbeddedValuesInPatterns(requestMapping.path())) + return RequestMappingInfo + .paths(resolveEmbeddedValuesInPatterns(requestMapping.path())) .methods(requestMapping.method()) .params(requestMapping.params()) .headers(requestMapping.headers())