28
28
import org .springframework .util .ObjectUtils ;
29
29
30
30
/**
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 .
34
34
*
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.
38
36
*
39
37
* @author Rossen Stoyanchev
40
38
* @since 5.0
39
+ * @see UriComponentsBuilder
41
40
*/
42
41
public class DefaultUriBuilderFactory implements UriBuilderFactory {
43
42
@@ -55,26 +54,28 @@ public enum EncodingMode {URI_COMPONENT, VALUES_ONLY, NONE };
55
54
56
55
/**
57
56
* Default constructor without a base URI.
57
+ * <p>The target address must be specified on each UriBuilder.
58
58
*/
59
59
public DefaultUriBuilderFactory () {
60
60
this (UriComponentsBuilder .newInstance ());
61
61
}
62
62
63
63
/**
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
71
71
*/
72
- public DefaultUriBuilderFactory (String baseUri ) {
73
- this (UriComponentsBuilder .fromUriString (baseUri ));
72
+ public DefaultUriBuilderFactory (String baseUriTemplate ) {
73
+ this (UriComponentsBuilder .fromUriString (baseUriTemplate ));
74
74
}
75
75
76
76
/**
77
- * Alternate constructor with a {@code UriComponentsBuilder} as the base URI.
77
+ * Variant of {@link #DefaultUriBuilderFactory(String)} with a
78
+ * {@code UriComponentsBuilder}.
78
79
*/
79
80
public DefaultUriBuilderFactory (UriComponentsBuilder baseUri ) {
80
81
Assert .notNull (baseUri , "'baseUri' is required." );
@@ -83,10 +84,9 @@ public DefaultUriBuilderFactory(UriComponentsBuilder baseUri) {
83
84
84
85
85
86
/**
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
90
90
*/
91
91
public void setDefaultUriVariables (@ Nullable Map <String , ?> defaultUriVariables ) {
92
92
this .defaultUriVariables .clear ();
0 commit comments