24
24
import org .springframework .http .HttpMethod ;
25
25
26
26
/**
27
- * Interface specifying a basic set of RESTful operations. Implemented by {@link RestTemplate}. Not often used directly,
28
- * but a useful option to enhance testability, as it can easily be mocked or stubbed.
27
+ * Interface specifying a basic set of RESTful operations. Implemented by {@link RestTemplate}.
28
+ * Not often used directly, but a useful option to enhance testability, as it can easily
29
+ * be mocked or stubbed.
29
30
*
30
31
* @author Arjen Poutsma
31
- * @see RestTemplate
32
+ * @author Juergen Hoeller
32
33
* @since 3.0
34
+ * @see RestTemplate
33
35
*/
34
36
public interface RestOperations {
35
37
36
38
// GET
37
39
38
40
/**
39
- * Retrieve a representation by doing a GET on the specified URL. The response (if any) is converted and returned.
41
+ * Retrieve a representation by doing a GET on the specified URL.
42
+ * The response (if any) is converted and returned.
40
43
* <p>URI Template variables are expanded using the given URI variables, if any.
41
- *
42
44
* @param url the URL
43
45
* @param responseType the type of the return value
44
46
* @param uriVariables the variables to expand the template
45
47
* @return the converted object
46
48
*/
47
- <T > T getForObject (String url , Class <T > responseType , String ... uriVariables ) throws RestClientException ;
49
+ <T > T getForObject (String url , Class <T > responseType , Object ... uriVariables ) throws RestClientException ;
48
50
49
51
/**
50
- * Retrieve a representation by doing a GET on the URI template. The response (if any) is converted and returned.
52
+ * Retrieve a representation by doing a GET on the URI template.
53
+ * The response (if any) is converted and returned.
51
54
* <p>URI Template variables are expanded using the given map.
52
- *
53
55
* @param url the URL
54
56
* @param responseType the type of the return value
55
57
* @param uriVariables the map containing variables for the URI template
56
58
* @return the converted object
57
59
*/
58
- <T > T getForObject (String url , Class <T > responseType , Map <String , String > uriVariables ) throws RestClientException ;
60
+ <T > T getForObject (String url , Class <T > responseType , Map <String , ? > uriVariables ) throws RestClientException ;
59
61
60
62
/**
61
- * Retrieve a representation by doing a GET on the URL . The response (if any) is converted and returned.
62
- *
63
+ * Retrieve a representation by doing a GET on the URL .
64
+ * The response (if any) is converted and returned.
63
65
* @param url the URL
64
66
* @param responseType the type of the return value
65
67
* @return the converted object
@@ -69,28 +71,25 @@ public interface RestOperations {
69
71
// HEAD
70
72
71
73
/**
72
- * Retrieve all headers of the resource specified by the URI template. <p>URI Template variables are expanded using the
73
- * given URI variables, if any.
74
- *
74
+ * Retrieve all headers of the resource specified by the URI template.
75
+ * <p>URI Template variables are expanded using the given URI variables, if any.
75
76
* @param url the URL
76
77
* @param uriVariables the variables to expand the template
77
78
* @return all HTTP headers of that resource
78
79
*/
79
- HttpHeaders headForHeaders (String url , String ... uriVariables ) throws RestClientException ;
80
+ HttpHeaders headForHeaders (String url , Object ... uriVariables ) throws RestClientException ;
80
81
81
82
/**
82
- * Retrieve all headers of the resource specified by the URI template. <p>URI Template variables are expanded using the
83
- * given map.
84
- *
83
+ * Retrieve all headers of the resource specified by the URI template.
84
+ * <p>URI Template variables are expanded using the given map.
85
85
* @param url the URL
86
86
* @param uriVariables the map containing variables for the URI template
87
87
* @return all HTTP headers of that resource
88
88
*/
89
- HttpHeaders headForHeaders (String url , Map <String , String > uriVariables ) throws RestClientException ;
89
+ HttpHeaders headForHeaders (String url , Map <String , ? > uriVariables ) throws RestClientException ;
90
90
91
91
/**
92
92
* Retrieve all headers of the resource specified by the URL.
93
- *
94
93
* @param url the URL
95
94
* @return all HTTP headers of that resource
96
95
*/
@@ -100,66 +99,62 @@ public interface RestOperations {
100
99
101
100
/**
102
101
* Create a new resource by POSTing the given object to the URI template, and returns the value of the
103
- * <code>Location</code> header. This header typically indicates where the new resource is stored. <p>URI Template
104
- * variables are expanded using the given URI variables, if any.
105
- *
102
+ * <code>Location</code> header. This header typically indicates where the new resource is stored.
103
+ * <p>URI Template variables are expanded using the given URI variables, if any.
106
104
* @param url the URL
107
105
* @param request the Object to be POSTed, may be <code>null</code>
108
106
* @param uriVariables the variables to expand the template
109
107
* @return the value for the <code>Location</code> header
110
108
*/
111
- URI postForLocation (String url , Object request , String ... uriVariables ) throws RestClientException ;
109
+ URI postForLocation (String url , Object request , Object ... uriVariables ) throws RestClientException ;
112
110
113
111
/**
114
112
* Create a new resource by POSTing the given object to the URI template, and returns the value of the
115
- * <code>Location</code> header. This header typically indicates where the new resource is stored. <p>URI Template
116
- * variables are expanded using the given map.
117
- *
113
+ * <code>Location</code> header. This header typically indicates where the new resource is stored.
114
+ * <p>URI Template variables are expanded using the given map.
118
115
* @param url the URL
119
116
* @param request the Object to be POSTed, may be <code>null</code>
120
117
* @param uriVariables the variables to expand the template
121
118
* @return the value for the <code>Location</code> header
122
119
*/
123
- URI postForLocation (String url , Object request , Map <String , String > uriVariables ) throws RestClientException ;
120
+ URI postForLocation (String url , Object request , Map <String , ? > uriVariables ) throws RestClientException ;
124
121
125
122
/**
126
123
* Create a new resource by POSTing the given object to the URL, and returns the value of the
127
124
* <code>Location</code> header. This header typically indicates where the new resource is stored.
128
- *
129
125
* @param url the URL
130
126
* @param request the Object to be POSTed, may be <code>null</code>
131
127
* @return the value for the <code>Location</code> header
132
128
*/
133
129
URI postForLocation (URI url , Object request ) throws RestClientException ;
134
130
135
131
/**
136
- * Create a new resource by POSTing the given object to the URI template, and returns the representation
137
- * found in the response. <p>URI Template variables are expanded using the given URI variables, if any .
138
- *
132
+ * Create a new resource by POSTing the given object to the URI template,
133
+ * and returns the representation found in the response .
134
+ * <p>URI Template variables are expanded using the given URI variables, if any.
139
135
* @param url the URL
140
136
* @param request the Object to be POSTed, may be <code>null</code>
141
137
* @param uriVariables the variables to expand the template
142
138
* @return the converted object
143
139
*/
144
- <T > T postForObject (String url , Object request , Class <T > responseType , String ... uriVariables )
140
+ <T > T postForObject (String url , Object request , Class <T > responseType , Object ... uriVariables )
145
141
throws RestClientException ;
146
142
147
143
/**
148
- * Create a new resource by POSTing the given object to the URI template, and returns the representation
149
- * found in the response. <p>URI Template variables are expanded using the given map .
150
- *
144
+ * Create a new resource by POSTing the given object to the URI template,
145
+ * and returns the representation found in the response .
146
+ * <p>URI Template variables are expanded using the given map.
151
147
* @param url the URL
152
148
* @param request the Object to be POSTed, may be <code>null</code>
153
149
* @param uriVariables the variables to expand the template
154
150
* @return the converted object
155
151
*/
156
- <T > T postForObject (String url , Object request , Class <T > responseType , Map <String , String > uriVariables )
152
+ <T > T postForObject (String url , Object request , Class <T > responseType , Map <String , ? > uriVariables )
157
153
throws RestClientException ;
158
154
159
155
/**
160
- * Create a new resource by POSTing the given object to the URL, and returns the representation
161
- * found in the response.
162
- *
156
+ * Create a new resource by POSTing the given object to the URL,
157
+ * and returns the representation found in the response.
163
158
* @param url the URL
164
159
* @param request the Object to be POSTed, may be <code>null</code>
165
160
* @return the converted object
@@ -169,28 +164,25 @@ <T> T postForObject(String url, Object request, Class<T> responseType, Map<Strin
169
164
// PUT
170
165
171
166
/**
172
- * Create or update a resource by PUTting the given object to the URI. <p>URI Template variables are expanded using the
173
- * given URI variables, if any.
174
- *
167
+ * Create or update a resource by PUTting the given object to the URI.
168
+ * <p>URI Template variables are expanded using the given URI variables, if any.
175
169
* @param url the URL
176
170
* @param request the Object to be PUT, may be <code>null</code>
177
171
* @param uriVariables the variables to expand the template
178
172
*/
179
- void put (String url , Object request , String ... uriVariables ) throws RestClientException ;
173
+ void put (String url , Object request , Object ... uriVariables ) throws RestClientException ;
180
174
181
175
/**
182
- * Creates a new resource by PUTting the given object to URI template. <p>URI Template variables are expanded using the
183
- * given map.
184
- *
176
+ * Creates a new resource by PUTting the given object to URI template.
177
+ * <p>URI Template variables are expanded using the given map.
185
178
* @param url the URL
186
179
* @param request the Object to be PUT, may be <code>null</code>
187
180
* @param uriVariables the variables to expand the template
188
181
*/
189
- void put (String url , Object request , Map <String , String > uriVariables ) throws RestClientException ;
182
+ void put (String url , Object request , Map <String , ? > uriVariables ) throws RestClientException ;
190
183
191
184
/**
192
185
* Creates a new resource by PUTting the given object to URL.
193
- *
194
186
* @param url the URL
195
187
* @param request the Object to be PUT, may be <code>null</code>
196
188
*/
@@ -199,53 +191,50 @@ <T> T postForObject(String url, Object request, Class<T> responseType, Map<Strin
199
191
// DELETE
200
192
201
193
/**
202
- * Delete the resources at the specified URI. <p>URI Template variables are expanded using the given URI variables, if
203
- * any.
204
- *
194
+ * Delete the resources at the specified URI.
195
+ * <p>URI Template variables are expanded using the given URI variables, if any.
205
196
* @param url the URL
206
197
* @param uriVariables the variables to expand in the template
207
198
*/
208
- void delete (String url , String ... uriVariables ) throws RestClientException ;
199
+ void delete (String url , Object ... uriVariables ) throws RestClientException ;
209
200
210
201
/**
211
- * Delete the resources at the specified URI. <p>URI Template variables are expanded using the given map.
202
+ * Delete the resources at the specified URI.
203
+ * <p>URI Template variables are expanded using the given map.
212
204
*
213
205
* @param url the URL
214
206
* @param uriVariables the variables to expand the template
215
207
*/
216
- void delete (String url , Map <String , String > uriVariables ) throws RestClientException ;
208
+ void delete (String url , Map <String , ? > uriVariables ) throws RestClientException ;
217
209
218
210
/**
219
211
* Delete the resources at the specified URL.
220
- *
221
212
* @param url the URL
222
213
*/
223
214
void delete (URI url ) throws RestClientException ;
224
215
225
216
// OPTIONS
226
217
227
218
/**
228
- * Return the value of the Allow header for the given URI. <p>URI Template variables are expanded using the given URI
229
- * variables, if any.
230
- *
219
+ * Return the value of the Allow header for the given URI.
220
+ * <p>URI Template variables are expanded using the given URI variables, if any.
231
221
* @param url the URL
232
222
* @param uriVariables the variables to expand in the template
233
223
* @return the value of the allow header
234
224
*/
235
- Set <HttpMethod > optionsForAllow (String url , String ... uriVariables ) throws RestClientException ;
225
+ Set <HttpMethod > optionsForAllow (String url , Object ... uriVariables ) throws RestClientException ;
236
226
237
227
/**
238
- * Return the value of the Allow header for the given URI. <p>URI Template variables are expanded using the given map.
239
- *
228
+ * Return the value of the Allow header for the given URI.
229
+ * <p>URI Template variables are expanded using the given map.
240
230
* @param url the URL
241
231
* @param uriVariables the variables to expand in the template
242
232
* @return the value of the allow header
243
233
*/
244
- Set <HttpMethod > optionsForAllow (String url , Map <String , String > uriVariables ) throws RestClientException ;
234
+ Set <HttpMethod > optionsForAllow (String url , Map <String , ? > uriVariables ) throws RestClientException ;
245
235
246
236
/**
247
237
* Return the value of the Allow header for the given URL.
248
- *
249
238
* @param url the URL
250
239
* @return the value of the allow header
251
240
*/
@@ -254,54 +243,43 @@ <T> T postForObject(String url, Object request, Class<T> responseType, Map<Strin
254
243
// general execution
255
244
256
245
/**
257
- * Execute the HTTP methods to the given URI template, preparing the request with the {@link RequestCallback}, and reading the
258
- * response with a {@link ResponseExtractor}. <p>URI Template variables are expanded using the given URI variables, if
259
- * any.
260
- *
246
+ * Execute the HTTP methods to the given URI template, preparing the request with the
247
+ * {@link RequestCallback}, and reading the response with a{@link ResponseExtractor}.
248
+ * <p>URI Template variables are expanded using the given URI variables, if any.
261
249
* @param url the URL
262
250
* @param method the HTTP method (GET, POST, etc)
263
251
* @param requestCallback object that prepares the request
264
252
* @param responseExtractor object that extracts the return value from the response
265
253
* @param uriVariables the variables to expand in the template
266
254
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
267
255
*/
268
- <T > T execute (String url ,
269
- HttpMethod method ,
270
- RequestCallback requestCallback ,
271
- ResponseExtractor <T > responseExtractor ,
272
- String ... uriVariables ) throws RestClientException ;
256
+ <T > T execute (String url , HttpMethod method , RequestCallback requestCallback ,
257
+ ResponseExtractor <T > responseExtractor , Object ... uriVariables ) throws RestClientException ;
273
258
274
259
/**
275
- * Execute the HTTP methods to the given URI template, preparing the request with the {@link RequestCallback}, and reading the
276
- * response with a {@link ResponseExtractor}. <p>URI Template variables are expanded using the given URI variables
277
- * map.
278
- *
260
+ * Execute the HTTP methods to the given URI template, preparing the request with the
261
+ * {@link RequestCallback}, and reading the response with a {@link ResponseExtractor}.
262
+ * <p>URI Template variables are expanded using the given URI variables map.
279
263
* @param url the URL
280
264
* @param method the HTTP method (GET, POST, etc)
281
265
* @param requestCallback object that prepares the request
282
266
* @param responseExtractor object that extracts the return value from the response
283
267
* @param uriVariables the variables to expand in the template
284
268
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
285
269
*/
286
- <T > T execute (String url ,
287
- HttpMethod method ,
288
- RequestCallback requestCallback ,
289
- ResponseExtractor <T > responseExtractor ,
290
- Map <String , String > uriVariables ) throws RestClientException ;
270
+ <T > T execute (String url , HttpMethod method , RequestCallback requestCallback ,
271
+ ResponseExtractor <T > responseExtractor , Map <String , ?> uriVariables ) throws RestClientException ;
291
272
292
273
/**
293
- * Execute the HTTP methods to the given URL, preparing the request with the {@link RequestCallback}, and reading the
294
- * response with a {@link ResponseExtractor}.
295
- *
274
+ * Execute the HTTP methods to the given URL, preparing the request with the
275
+ * {@link RequestCallback}, and reading the response with a {@link ResponseExtractor}.
296
276
* @param url the URL
297
277
* @param method the HTTP method (GET, POST, etc)
298
278
* @param requestCallback object that prepares the request
299
279
* @param responseExtractor object that extracts the return value from the response
300
280
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
301
281
*/
302
- <T > T execute (URI url ,
303
- HttpMethod method ,
304
- RequestCallback requestCallback ,
282
+ <T > T execute (URI url , HttpMethod method , RequestCallback requestCallback ,
305
283
ResponseExtractor <T > responseExtractor ) throws RestClientException ;
306
284
307
285
}
0 commit comments