@@ -93,9 +93,8 @@ public class MvcUriComponentsBuilder extends UriComponentsBuilder {
93
93
* Create a {@link UriComponentsBuilder} from the mapping of a controller class
94
94
* and current request information including Servlet mapping. If the controller
95
95
* contains multiple mappings, only the first one is used.
96
- *
97
96
* @param controllerType the controller to build a URI for
98
- * @return a UriComponentsBuilder instance, never {@code null}
97
+ * @return a UriComponentsBuilder instance ( never {@code null})
99
98
*/
100
99
public static UriComponentsBuilder fromController (Class <?> controllerType ) {
101
100
String mapping = getTypeRequestMapping (controllerType );
@@ -120,14 +119,11 @@ private static String getTypeRequestMapping(Class<?> controllerType) {
120
119
* Create a {@link UriComponentsBuilder} from the mapping of a controller method
121
120
* and an array of method argument values. This method delegates to
122
121
* {@link #fromMethod(java.lang.reflect.Method, Object...)}.
123
- *
124
122
* @param controllerType the controller
125
123
* @param methodName the method name
126
124
* @param argumentValues the argument values
127
125
* @return a UriComponentsBuilder instance, never {@code null}
128
- *
129
- * @throws java.lang.IllegalStateException if there is no matching or more than
130
- * one matching method.
126
+ * @throws IllegalStateException if there is no matching or more than one matching method
131
127
*/
132
128
public static UriComponentsBuilder fromMethodName (Class <?> controllerType , String methodName , Object ... argumentValues ) {
133
129
Method method = getMethod (controllerType , methodName , argumentValues );
@@ -156,8 +152,7 @@ private static Method getMethod(Class<?> controllerType, String methodName, Obje
156
152
* Create a {@link UriComponentsBuilder} by invoking a "mock" controller method.
157
153
* The controller method and the supplied argument values are then used to
158
154
* delegate to {@link #fromMethod(java.lang.reflect.Method, Object...)}.
159
- * <p>
160
- * For example given this controller:
155
+ * <p>For example, given this controller:
161
156
* <pre class="code">
162
157
* @RequestMapping("/people/{id}/addresses")
163
158
* class AddressController {
@@ -184,7 +179,6 @@ private static Method getMethod(Class<?> controllerType, String methodName, Obje
184
179
* controller.getAddressesForCountry("US")
185
180
* builder = MvcUriComponentsBuilder.fromMethodCall(controller);
186
181
* </pre>
187
- *
188
182
* @param invocationInfo either the value returned from a "mock" controller
189
183
* invocation or the "mock" controller itself after an invocation
190
184
* @return a UriComponents instance
@@ -202,20 +196,17 @@ public static UriComponentsBuilder fromMethodCall(Object invocationInfo) {
202
196
* {@code @PathVariable} are used for building the URI (via implementations of
203
197
* {@link org.springframework.web.method.support.UriComponentsContributor})
204
198
* while remaining argument values are ignored and can be {@code null}.
205
- *
206
199
* @param method the controller method
207
200
* @param argumentValues argument values for the controller method
208
201
* @return a UriComponentsBuilder instance, never {@code null}
209
202
*/
210
203
public static UriComponentsBuilder fromMethod (Method method , Object ... argumentValues ) {
211
-
212
204
String typePath = getTypeRequestMapping (method .getDeclaringClass ());
213
205
String methodPath = getMethodRequestMapping (method );
214
206
String path = pathMatcher .combine (typePath , methodPath );
215
207
216
208
UriComponentsBuilder builder = ServletUriComponentsBuilder .fromCurrentServletMapping ().path (path );
217
209
UriComponents uriComponents = applyContributors (builder , method , argumentValues );
218
-
219
210
return ServletUriComponentsBuilder .newInstance ().uriComponents (uriComponents );
220
211
}
221
212
@@ -246,14 +237,13 @@ private static UriComponents applyContributors(UriComponentsBuilder builder, Met
246
237
" does not match number of argument values " + argCount );
247
238
248
239
final Map <String , Object > uriVars = new HashMap <String , Object >();
249
- for (int i = 0 ; i < paramCount ; i ++) {
240
+ for (int i = 0 ; i < paramCount ; i ++) {
250
241
MethodParameter param = new MethodParameter (method , i );
251
242
param .initParameterNameDiscovery (parameterNameDiscoverer );
252
243
contributor .contributeMethodArgument (param , args [i ], builder , uriVars );
253
244
}
254
245
255
246
// We may not have all URI var values, expand only what we have
256
-
257
247
return builder .build ().expand (new UriComponents .UriTemplateVariables () {
258
248
@ Override
259
249
public Object getValue (String name ) {
0 commit comments