Skip to content

Commit cbe5a67

Browse files
committed
Polish
1 parent 9fc4fb1 commit cbe5a67

File tree

3 files changed

+34
-37
lines changed

3 files changed

+34
-37
lines changed

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@
2828
import org.springframework.util.ObjectUtils;
2929

3030
/**
31-
* Default implementation of {@link UriBuilderFactory} using
32-
* {@link UriComponentsBuilder} for building, encoding, and expanding URI
33-
* templates.
31+
* Default implementation of {@link UriBuilderFactory} providing options to
32+
* pre-configure all UriBuilder instances with common properties such as a base
33+
* URI, encoding mode, and default URI variables.
3434
*
35-
* <p>Exposes configuration properties that customize the creation of all URIs
36-
* built through this factory instance including a base URI, default URI
37-
* variables, and an encoding mode.
35+
* <p>Uses {@link UriComponentsBuilder} for URI building.
3836
*
3937
* @author Rossen Stoyanchev
4038
* @since 5.0
39+
* @see UriComponentsBuilder
4140
*/
4241
public class DefaultUriBuilderFactory implements UriBuilderFactory {
4342

@@ -55,26 +54,28 @@ public enum EncodingMode {URI_COMPONENT, VALUES_ONLY, NONE };
5554

5655
/**
5756
* Default constructor without a base URI.
57+
* <p>The target address must be specified on each UriBuilder.
5858
*/
5959
public DefaultUriBuilderFactory() {
6060
this(UriComponentsBuilder.newInstance());
6161
}
6262

6363
/**
64-
* Constructor with a String "base URI".
65-
* <p>The String given here is used to create a single "base"
66-
* {@code UriComponentsBuilder}. Each time a new URI is prepared via
67-
* {@link #uriString(String)} a new {@code UriComponentsBuilder} is created and
68-
* merged with a clone of the "base" {@code UriComponentsBuilder}.
69-
* <p>Note that the base URI may contain any or all components of a URI and
70-
* those will apply to every URI.
64+
* Constructor with a base URI.
65+
* <p>The given URI template is parsed via
66+
* {@link UriComponentsBuilder#fromUriString} and then applied as a base URI
67+
* to every UriBuilder via {@link UriComponentsBuilder#uriComponents} unless
68+
* the UriBuilder itself was created with a URI template that already has a
69+
* target address.
70+
* @param baseUriTemplate the URI template to use a base URL
7171
*/
72-
public DefaultUriBuilderFactory(String baseUri) {
73-
this(UriComponentsBuilder.fromUriString(baseUri));
72+
public DefaultUriBuilderFactory(String baseUriTemplate) {
73+
this(UriComponentsBuilder.fromUriString(baseUriTemplate));
7474
}
7575

7676
/**
77-
* Alternate constructor with a {@code UriComponentsBuilder} as the base URI.
77+
* Variant of {@link #DefaultUriBuilderFactory(String)} with a
78+
* {@code UriComponentsBuilder}.
7879
*/
7980
public DefaultUriBuilderFactory(UriComponentsBuilder baseUri) {
8081
Assert.notNull(baseUri, "'baseUri' is required.");
@@ -83,10 +84,9 @@ public DefaultUriBuilderFactory(UriComponentsBuilder baseUri) {
8384

8485

8586
/**
86-
* Configure default URI variable values to use when expanding a URI with a
87-
* Map of values. The map supplied when expanding a given URI can override
88-
* default values.
89-
* @param defaultUriVariables the default URI variables
87+
* Provide default URI variable values to use when expanding URI templates
88+
* with a Map of variables.
89+
* @param defaultUriVariables default URI variable values
9090
*/
9191
public void setDefaultUriVariables(@Nullable Map<String, ?> defaultUriVariables) {
9292
this.defaultUriVariables.clear();

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,25 @@
1616
package org.springframework.web.util;
1717

1818
/**
19-
* Factory for instances of {@link UriBuilder}.
20-
*
21-
* <p>A single {@link UriBuilderFactory} may be created once, configured with
22-
* common properties such as a base URI, and then used to create many URIs.
23-
*
24-
* <p>Extends {@link UriTemplateHandler} which has a similar purpose but only
25-
* provides shortcuts for expanding URI templates, not builder style methods.
19+
* Factory to create {@link UriBuilder} instances pre-configured in a specific
20+
* way such as sharing a common base URI across all builders.
2621
*
2722
* @author Rossen Stoyanchev
2823
* @since 5.0
2924
*/
3025
public interface UriBuilderFactory extends UriTemplateHandler {
3126

3227
/**
33-
* Return a builder initialized with the given URI string.
34-
* <p>Concrete implementations may apply further initializations such as
35-
* combining with a pre-configured base URI.
36-
* @param uriTemplate the URI template to initialize the builder with
37-
* @return the UriBuilder
28+
* Create a builder from the given URI template string.
29+
* Implementations may further combine the URI template with a base URI.
30+
* @param uriTemplate the URI template to use
31+
* @return the builder instance
3832
*/
3933
UriBuilder uriString(String uriTemplate);
4034

4135
/**
42-
* Return a builder to prepare a new URI.
43-
* @return the UriBuilder
36+
* Create a builder with default settings.
37+
* @return the builder instance
4438
*/
4539
UriBuilder builder();
4640

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,12 @@ public UriComponentsBuilder uri(URI uri) {
444444
}
445445

446446
/**
447-
* Initialize components of this {@code UriComponentsBuilder} from the
448-
* components of the given {@link UriComponents}.
449-
* @param uriComponents the UriComponents instance
447+
* Set or append individual URI components of this builder from the values
448+
* of the given {@link UriComponents} instance.
449+
* <p>For the semantics of each component (i.e. set vs append) check the
450+
* builder methods on this class. For example {@link #host(String)} sets
451+
* while {@link #path(String)} appends.
452+
* @param uriComponents the UriComponents to copy from
450453
* @return this UriComponentsBuilder
451454
*/
452455
public UriComponentsBuilder uriComponents(UriComponents uriComponents) {

0 commit comments

Comments
 (0)