Polishing

This commit is contained in:
Juergen Hoeller
2019-06-11 23:50:29 +02:00
parent 22aba8bf60
commit 33b5bc2aae
8 changed files with 60 additions and 54 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ import org.springframework.web.util.pattern.PathPattern;
/**
* {@code HandlerMapping} implementation that supports {@link RouterFunction RouterFunctions}.
*
* <p>If no {@link RouterFunction} is provided at
* {@linkplain #RouterFunctionMapping(RouterFunction) construction time}, this mapping
* will detect all router functions in the application context, and consult them in
@@ -56,8 +57,8 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
/**
* Create an empty {@code RouterFunctionMapping}.
* <p>If this constructor is used, this mapping will detect all {@link RouterFunction} instances
* available in the application context.
* <p>If this constructor is used, this mapping will detect all
* {@link RouterFunction} instances available in the application context.
*/
public RouterFunctionMapping() {
}
@@ -154,20 +155,18 @@ public class RouterFunctionMapping extends AbstractHandlerMapping implements Ini
}
@SuppressWarnings("unchecked")
private void setAttributes(Map<String, Object> attributes, ServerRequest serverRequest,
HandlerFunction<?> handlerFunction) {
private void setAttributes(
Map<String, Object> attributes, ServerRequest serverRequest, HandlerFunction<?> handlerFunction) {
attributes.put(RouterFunctions.REQUEST_ATTRIBUTE, serverRequest);
attributes.put(BEST_MATCHING_HANDLER_ATTRIBUTE, handlerFunction);
PathPattern matchingPattern =
(PathPattern) attributes.get(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE);
PathPattern matchingPattern = (PathPattern) attributes.get(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE);
if (matchingPattern != null) {
attributes.put(BEST_MATCHING_PATTERN_ATTRIBUTE, matchingPattern);
}
Map<String, String> uriVariables =
(Map<String, String>) attributes
.get(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
(Map<String, String>) attributes.get(RouterFunctions.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
if (uriVariables != null) {
attributes.put(URI_TEMPLATE_VARIABLES_ATTRIBUTE, uriVariables);
}