Skip to content

Commit 545c28f

Browse files
committed
Minor UriComponentsBuilder javadoc revision
1 parent 95a7bfd commit 545c28f

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -253,18 +253,18 @@ public static UriComponentsBuilder fromHttpUrl(String httpUrl) {
253253
// build methods
254254

255255
/**
256-
* Builds a {@code UriComponents} instance from the various components contained in this builder.
256+
* Build a {@code UriComponents} instance from the various components contained in this builder.
257257
* @return the URI components
258258
*/
259259
public UriComponents build() {
260260
return build(false);
261261
}
262262

263263
/**
264-
* Builds a {@code UriComponents} instance from the various components
264+
* Build a {@code UriComponents} instance from the various components
265265
* contained in this builder.
266266
* @param encoded whether all the components set in this builder are
267-
* encoded ({@code true}) or not ({@code false}).
267+
* encoded ({@code true}) or not ({@code false}).
268268
* @return the URI components
269269
*/
270270
public UriComponents build(boolean encoded) {
@@ -278,8 +278,8 @@ public UriComponents build(boolean encoded) {
278278
}
279279

280280
/**
281-
* Builds a {@code UriComponents} instance and replaces URI template variables
282-
* with the values from a map. This is a shortcut method, which combines
281+
* Build a {@code UriComponents} instance and replaces URI template variables
282+
* with the values from a map. This is a shortcut method which combines
283283
* calls to {@link #build()} and then {@link UriComponents#expand(Map)}.
284284
* @param uriVariables the map of URI variables
285285
* @return the URI components with expanded values
@@ -289,8 +289,8 @@ public UriComponents buildAndExpand(Map<String, ?> uriVariables) {
289289
}
290290

291291
/**
292-
* Builds a {@code UriComponents} instance and replaces URI template variables
293-
* with the values from an array. This is a shortcut method, which combines
292+
* Build a {@code UriComponents} instance and replaces URI template variables
293+
* with the values from an array. This is a shortcut method which combines
294294
* calls to {@link #build()} and then {@link UriComponents#expand(Object...)}.
295295
* @param uriVariableValues URI variable values
296296
* @return the URI components with expanded values

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ public class MvcUriComponentsBuilder extends UriComponentsBuilder {
9393
* Create a {@link UriComponentsBuilder} from the mapping of a controller class
9494
* and current request information including Servlet mapping. If the controller
9595
* contains multiple mappings, only the first one is used.
96-
*
9796
* @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})
9998
*/
10099
public static UriComponentsBuilder fromController(Class<?> controllerType) {
101100
String mapping = getTypeRequestMapping(controllerType);
@@ -120,14 +119,11 @@ private static String getTypeRequestMapping(Class<?> controllerType) {
120119
* Create a {@link UriComponentsBuilder} from the mapping of a controller method
121120
* and an array of method argument values. This method delegates to
122121
* {@link #fromMethod(java.lang.reflect.Method, Object...)}.
123-
*
124122
* @param controllerType the controller
125123
* @param methodName the method name
126124
* @param argumentValues the argument values
127125
* @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
131127
*/
132128
public static UriComponentsBuilder fromMethodName(Class<?> controllerType, String methodName, Object... argumentValues) {
133129
Method method = getMethod(controllerType, methodName, argumentValues);
@@ -156,8 +152,7 @@ private static Method getMethod(Class<?> controllerType, String methodName, Obje
156152
* Create a {@link UriComponentsBuilder} by invoking a "mock" controller method.
157153
* The controller method and the supplied argument values are then used to
158154
* delegate to {@link #fromMethod(java.lang.reflect.Method, Object...)}.
159-
* <p>
160-
* For example given this controller:
155+
* <p>For example, given this controller:
161156
* <pre class="code">
162157
* &#064;RequestMapping("/people/{id}/addresses")
163158
* class AddressController {
@@ -184,7 +179,6 @@ private static Method getMethod(Class<?> controllerType, String methodName, Obje
184179
* controller.getAddressesForCountry("US")
185180
* builder = MvcUriComponentsBuilder.fromMethodCall(controller);
186181
* </pre>
187-
*
188182
* @param invocationInfo either the value returned from a "mock" controller
189183
* invocation or the "mock" controller itself after an invocation
190184
* @return a UriComponents instance
@@ -202,20 +196,17 @@ public static UriComponentsBuilder fromMethodCall(Object invocationInfo) {
202196
* {@code @PathVariable} are used for building the URI (via implementations of
203197
* {@link org.springframework.web.method.support.UriComponentsContributor})
204198
* while remaining argument values are ignored and can be {@code null}.
205-
*
206199
* @param method the controller method
207200
* @param argumentValues argument values for the controller method
208201
* @return a UriComponentsBuilder instance, never {@code null}
209202
*/
210203
public static UriComponentsBuilder fromMethod(Method method, Object... argumentValues) {
211-
212204
String typePath = getTypeRequestMapping(method.getDeclaringClass());
213205
String methodPath = getMethodRequestMapping(method);
214206
String path = pathMatcher.combine(typePath, methodPath);
215207

216208
UriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentServletMapping().path(path);
217209
UriComponents uriComponents = applyContributors(builder, method, argumentValues);
218-
219210
return ServletUriComponentsBuilder.newInstance().uriComponents(uriComponents);
220211
}
221212

@@ -246,14 +237,13 @@ private static UriComponents applyContributors(UriComponentsBuilder builder, Met
246237
" does not match number of argument values " + argCount);
247238

248239
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++) {
250241
MethodParameter param = new MethodParameter(method, i);
251242
param.initParameterNameDiscovery(parameterNameDiscoverer);
252243
contributor.contributeMethodArgument(param, args[i], builder, uriVars);
253244
}
254245

255246
// We may not have all URI var values, expand only what we have
256-
257247
return builder.build().expand(new UriComponents.UriTemplateVariables() {
258248
@Override
259249
public Object getValue(String name) {

0 commit comments

Comments
 (0)