@@ -63,10 +63,10 @@ public class HttpRequestValues {
63
63
private final URI uri ;
64
64
65
65
@ Nullable
66
- private final String uriTemplate ;
66
+ private final UriBuilderFactory uriBuilderFactory ;
67
67
68
68
@ Nullable
69
- private final UriBuilderFactory uriBuilderFactory ;
69
+ private final String uriTemplate ;
70
70
71
71
private final Map <String , String > uriVariables ;
72
72
@@ -81,11 +81,10 @@ public class HttpRequestValues {
81
81
82
82
83
83
/**
84
- * Construct {@link HttpRequestValues}.
85
- *
86
- * @deprecated in favour of {@link HttpRequestValues#HttpRequestValues(
87
- * HttpMethod, URI, String, UriBuilderFactory, Map, HttpHeaders,
88
- * MultiValueMap, Map, Object)} to be removed in 6.2.
84
+ * Constructor without UriBuilderFactory.
85
+ * @deprecated in favour of
86
+ * {@link HttpRequestValues#HttpRequestValues(HttpMethod, URI, UriBuilderFactory, String, Map, HttpHeaders, MultiValueMap, Map, Object)}
87
+ * to be removed in 6.2.
89
88
*/
90
89
@ Deprecated (since = "6.1" , forRemoval = true )
91
90
protected HttpRequestValues (@ Nullable HttpMethod httpMethod ,
@@ -94,22 +93,25 @@ protected HttpRequestValues(@Nullable HttpMethod httpMethod,
94
93
HttpHeaders headers , MultiValueMap <String , String > cookies , Map <String , Object > attributes ,
95
94
@ Nullable Object bodyValue ) {
96
95
97
- this (httpMethod , uri , uriTemplate , null , uriVariables ,
98
- headers , cookies , attributes , bodyValue );
96
+ this (httpMethod , uri , null , uriTemplate , uriVariables , headers , cookies , attributes , bodyValue );
99
97
}
100
98
99
+ /**
100
+ * Construct {@link HttpRequestValues}.
101
+ * @since 6.1
102
+ */
101
103
protected HttpRequestValues (@ Nullable HttpMethod httpMethod ,
102
- @ Nullable URI uri , @ Nullable String uriTemplate ,
103
- @ Nullable UriBuilderFactory uriBuilderFactory , Map <String , String > uriVariables ,
104
+ @ Nullable URI uri , @ Nullable UriBuilderFactory uriBuilderFactory ,
105
+ @ Nullable String uriTemplate , Map <String , String > uriVariables ,
104
106
HttpHeaders headers , MultiValueMap <String , String > cookies , Map <String , Object > attributes ,
105
107
@ Nullable Object bodyValue ) {
106
108
107
109
Assert .isTrue (uri != null || uriTemplate != null , "Neither URI nor URI template" );
108
110
109
111
this .httpMethod = httpMethod ;
110
112
this .uri = uri ;
111
- this .uriTemplate = uriTemplate ;
112
113
this .uriBuilderFactory = uriBuilderFactory ;
114
+ this .uriTemplate = uriTemplate ;
113
115
this .uriVariables = uriVariables ;
114
116
this .headers = headers ;
115
117
this .cookies = cookies ;
@@ -138,25 +140,25 @@ public URI getUri() {
138
140
}
139
141
140
142
/**
141
- * Return the URL template for the request. This comes from the values in
142
- * class and method {@code HttpExchange} annotations.
143
+ * Return the {@link UriBuilderFactory} to expand
144
+ * the {@link HttpRequestValues#uriTemplate} and {@link #getUriVariables()} with.
145
+ * <p>The {@link UriBuilderFactory} is passed into the HTTP interface method
146
+ * in order to override the UriBuilderFactory (and its baseUrl) used by the
147
+ * underlying client.
148
+ * @since 6.1
143
149
*/
144
150
@ Nullable
145
- public String getUriTemplate () {
146
- return this .uriTemplate ;
151
+ public UriBuilderFactory getUriBuilderFactory () {
152
+ return this .uriBuilderFactory ;
147
153
}
148
154
149
155
/**
150
- * Return the {@link UriBuilderFactory} to expand
151
- * the {@link HttpRequestValues#uriTemplate} with.
152
- * <p>This comes from a {@link UriBuilderFactory} method argument.
153
- * It allows you to override the {@code baseUri}, while keeping the
154
- * path as defined in class and method
155
- * {@code HttpExchange} annotations.
156
+ * Return the URL template for the request. This comes from the values in
157
+ * class and method {@code HttpExchange} annotations.
156
158
*/
157
159
@ Nullable
158
- public UriBuilderFactory getUriBuilderFactory () {
159
- return this .uriBuilderFactory ;
160
+ public String getUriTemplate () {
161
+ return this .uriTemplate ;
160
162
}
161
163
162
164
/**
@@ -237,10 +239,10 @@ public static class Builder {
237
239
private URI uri ;
238
240
239
241
@ Nullable
240
- private String uriTemplate ;
242
+ private UriBuilderFactory uriBuilderFactory ;
241
243
242
244
@ Nullable
243
- private UriBuilderFactory uriBuilderFactory ;
245
+ private String uriTemplate ;
244
246
245
247
@ Nullable
246
248
private Map <String , String > uriVars ;
@@ -282,19 +284,20 @@ public Builder setUri(URI uri) {
282
284
}
283
285
284
286
/**
285
- * Set the request URL as a String template.
287
+ * Set the {@link UriBuilderFactory} that will be used to expand the
288
+ * {@link #getUriTemplate()}.
289
+ * @since 6.1
286
290
*/
287
- public Builder setUriTemplate ( String uriTemplate ) {
288
- this .uriTemplate = uriTemplate ;
291
+ public Builder setUriBuilderFactory ( @ Nullable UriBuilderFactory uriBuilderFactory ) {
292
+ this .uriBuilderFactory = uriBuilderFactory ;
289
293
return this ;
290
294
}
291
295
292
296
/**
293
- * Set the {@link UriBuilderFactory} that
294
- * will be used to expand the URI.
297
+ * Set the request URL as a String template.
295
298
*/
296
- public Builder setUriBuilderFactory ( @ Nullable UriBuilderFactory uriBuilderFactory ) {
297
- this .uriBuilderFactory = uriBuilderFactory ;
299
+ public Builder setUriTemplate ( String uriTemplate ) {
300
+ this .uriTemplate = uriTemplate ;
298
301
return this ;
299
302
}
300
303
@@ -427,8 +430,8 @@ public <T, P extends Publisher<T>> void setBody(P body, ParameterizedTypeReferen
427
430
public HttpRequestValues build () {
428
431
429
432
URI uri = this .uri ;
430
- String uriTemplate = (this .uriTemplate != null ? this .uriTemplate : "" );
431
433
UriBuilderFactory uriBuilderFactory = this .uriBuilderFactory ;
434
+ String uriTemplate = (this .uriTemplate != null ? this .uriTemplate : "" );
432
435
Map <String , String > uriVars = (this .uriVars != null ? new HashMap <>(this .uriVars ) : Collections .emptyMap ());
433
436
434
437
Object bodyValue = this .bodyValue ;
@@ -470,8 +473,8 @@ else if (uri != null) {
470
473
new HashMap <>(this .attributes ) : Collections .emptyMap ());
471
474
472
475
return createRequestValues (
473
- this .httpMethod , uri , uriTemplate , uriBuilderFactory ,
474
- uriVars , headers , cookies , attributes , bodyValue );
476
+ this .httpMethod , uri , uriBuilderFactory , uriTemplate , uriVars ,
477
+ headers , cookies , attributes , bodyValue );
475
478
}
476
479
477
480
protected boolean hasParts () {
@@ -512,9 +515,9 @@ private String appendQueryParams(
512
515
513
516
/**
514
517
* Create {@link HttpRequestValues} from values passed to the {@link Builder}.
515
- * @deprecated in favour of {@link Builder#createRequestValues(
516
- * HttpMethod, URI, String, UriBuilderFactory , Map, HttpHeaders,
517
- * MultiValueMap, Map, Object)} to be removed in 6.2.
518
+ * @deprecated in favour of
519
+ * {@link Builder#createRequestValues( HttpMethod, URI, UriBuilderFactory, String , Map, HttpHeaders, MultiValueMap, Map, Object)}
520
+ * to be removed in 6.2.
518
521
*/
519
522
@ Deprecated (since = "6.1" , forRemoval = true )
520
523
protected HttpRequestValues createRequestValues (
@@ -524,22 +527,23 @@ protected HttpRequestValues createRequestValues(
524
527
HttpHeaders headers , MultiValueMap <String , String > cookies , Map <String , Object > attributes ,
525
528
@ Nullable Object bodyValue ) {
526
529
527
- return createRequestValues (httpMethod , uri , uriTemplate , null ,
530
+ return createRequestValues (httpMethod , uri , null , uriTemplate ,
528
531
uriVars , headers , cookies , attributes , bodyValue );
529
532
}
530
533
531
534
/**
532
535
* Create {@link HttpRequestValues} from values passed to the {@link Builder}.
536
+ * @since 6.1
533
537
*/
534
538
protected HttpRequestValues createRequestValues (
535
539
@ Nullable HttpMethod httpMethod ,
536
- @ Nullable URI uri , @ Nullable String uriTemplate ,
537
- @ Nullable UriBuilderFactory uriBuilderFactory , Map <String , String > uriVars ,
540
+ @ Nullable URI uri , @ Nullable UriBuilderFactory uriBuilderFactory , @ Nullable String uriTemplate ,
541
+ Map <String , String > uriVars ,
538
542
HttpHeaders headers , MultiValueMap <String , String > cookies , Map <String , Object > attributes ,
539
543
@ Nullable Object bodyValue ) {
540
544
541
545
return new HttpRequestValues (
542
- this .httpMethod , uri , uriTemplate , uriBuilderFactory ,
546
+ this .httpMethod , uri , uriBuilderFactory , uriTemplate ,
543
547
uriVars , headers , cookies , attributes , bodyValue );
544
548
}
545
549
}
0 commit comments