@@ -25,8 +25,10 @@ import org.springframework.web.client.RestClientException
25
25
import java.net.URI
26
26
27
27
/* *
28
- * Extension for [TestRestTemplate.getForObject] avoiding specifying the type
29
- * parameter thanks to Kotlin reified type parameters.
28
+ * Extension for [TestRestTemplate.getForObject] providing a `getForObject<Foo>(...)`
29
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
30
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
31
+ * generic type arguments.
30
32
*
31
33
* @author Sebastien Deleuze
32
34
* @since 2.0.0
@@ -36,8 +38,10 @@ inline fun <reified T : Any> TestRestTemplate.getForObject(url: String, vararg u
36
38
getForObject(url, T ::class .java, * uriVariables)
37
39
38
40
/* *
39
- * Extension for [TestRestTemplate.getForObject] avoiding specifying the type
40
- * parameter thanks to Kotlin reified type parameters.
41
+ * Extension for [TestRestTemplate.getForObject] providing a `getForObject<Foo>(...)`
42
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
43
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
44
+ * generic type arguments.
41
45
*
42
46
* @author Sebastien Deleuze
43
47
* @since 2.0.0
@@ -47,8 +51,10 @@ inline fun <reified T : Any> TestRestTemplate.getForObject(url: String, uriVaria
47
51
getForObject(url, T ::class .java, uriVariables)
48
52
49
53
/* *
50
- * Extension for [TestRestTemplate.getForObject] avoiding specifying the type parameter
51
- * thanks to Kotlin reified type parameters.
54
+ * Extension for [TestRestTemplate.getForObject] providing a `getForObject<Foo>(...)`
55
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
56
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
57
+ * generic type arguments.
52
58
*
53
59
* @author Sebastien Deleuze
54
60
* @since 2.0.0
@@ -58,8 +64,10 @@ inline fun <reified T : Any> TestRestTemplate.getForObject(url: URI): T? =
58
64
getForObject(url, T ::class .java)
59
65
60
66
/* *
61
- * Extension for [TestRestTemplate.getForEntity] avoiding requiring the type parameter
62
- * thanks to Kotlin reified type parameters.
67
+ * Extension for [TestRestTemplate.getForEntity] providing a `getForEntity<Foo>(...)`
68
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
69
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
70
+ * generic type arguments.
63
71
*
64
72
* @author Sebastien Deleuze
65
73
* @since 2.0.0
@@ -69,8 +77,10 @@ inline fun <reified T : Any> TestRestTemplate.getForEntity(url: URI): ResponseEn
69
77
getForEntity(url, T ::class .java)
70
78
71
79
/* *
72
- * Extension for [TestRestTemplate.getForEntity] avoiding requiring the type parameter
73
- * thanks to Kotlin reified type parameters.
80
+ * Extension for [TestRestTemplate.getForEntity] providing a `getForEntity<Foo>(...)`
81
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
82
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
83
+ * generic type arguments.
74
84
*
75
85
* @author Sebastien Deleuze
76
86
* @since 2.0.0
@@ -80,8 +90,10 @@ inline fun <reified T : Any> TestRestTemplate.getForEntity(url: String, vararg u
80
90
getForEntity(url, T ::class .java, * uriVariables)
81
91
82
92
/* *
83
- * Extension for [TestRestTemplate.getForEntity] avoiding requiring the type parameter
84
- * thanks to Kotlin reified type parameters.
93
+ * Extension for [TestRestTemplate.getForEntity] providing a `getForEntity<Foo>(...)`
94
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
95
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
96
+ * generic type arguments.
85
97
*
86
98
* @author Sebastien Deleuze
87
99
* @since 2.0.0
@@ -91,140 +103,171 @@ inline fun <reified T : Any> TestRestTemplate.getForEntity(url: String, uriVaria
91
103
getForEntity(url, T ::class .java, uriVariables)
92
104
93
105
/* *
94
- * Extension for [TestRestTemplate.patchForObject] avoiding specifying the type parameter
95
- * thanks to Kotlin reified type parameters.
106
+ * Extension for [TestRestTemplate.patchForObject] providing a `patchForObject<Foo>(...)`
107
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
108
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
109
+ * generic type arguments.
96
110
*
97
111
* @author Sebastien Deleuze
98
112
* @since 2.0.0
99
113
*/
100
114
@Throws(RestClientException ::class )
101
- inline fun <reified T : Any > TestRestTemplate.patchForObject (url : String , request : Any , vararg uriVariables : Any ): T ? =
115
+ inline fun <reified T : Any > TestRestTemplate.patchForObject (url : String , request : Any? = null,
116
+ vararg uriVariables : Any ): T ? =
102
117
patchForObject(url, request, T ::class .java, * uriVariables)
103
118
104
119
/* *
105
- * Extension for [TestRestTemplate.patchForObject] avoiding specifying the type parameter
106
- * thanks to Kotlin reified type parameters.
120
+ * Extension for [TestRestTemplate.patchForObject] providing a `patchForObject<Foo>(...)`
121
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
122
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
123
+ * generic type arguments.
107
124
*
108
125
* @author Sebastien Deleuze
109
126
* @since 2.0.0
110
127
*/
111
128
@Throws(RestClientException ::class )
112
- inline fun <reified T : Any > TestRestTemplate.patchForObject (url : String , request : Any , uriVariables : Map <String , * >): T ? =
129
+ inline fun <reified T : Any > TestRestTemplate.patchForObject (url : String , request : Any? = null,
130
+ uriVariables : Map <String , * >): T ? =
113
131
patchForObject(url, request, T ::class .java, uriVariables)
114
132
115
133
/* *
116
- * Extension for [TestRestTemplate.patchForObject] avoiding specifying the type parameter
117
- * thanks to Kotlin reified type parameters.
134
+ * Extension for [TestRestTemplate.patchForObject] providing a `patchForObject<Foo>(...)`
135
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
136
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
137
+ * generic type arguments.
118
138
*
119
139
* @author Sebastien Deleuze
120
140
* @since 2.0.0
121
141
*/
122
142
@Throws(RestClientException ::class )
123
- inline fun <reified T : Any > TestRestTemplate.patchForObject (url : URI , request : Any ): T ? =
143
+ inline fun <reified T : Any > TestRestTemplate.patchForObject (url : URI , request : Any? = null ): T ? =
124
144
patchForObject(url, request, T ::class .java)
125
145
126
146
/* *
127
- * Extension for [TestRestTemplate.postForObject] avoiding specifying the type parameter
128
- * thanks to Kotlin reified type parameters.
147
+ * Extension for [TestRestTemplate.postForObject] providing a `postForObject<Foo>(...)`
148
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
149
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
150
+ * generic type arguments.
129
151
*
130
152
* @author Sebastien Deleuze
131
153
* @since 2.0.0
132
154
*/
133
155
@Throws(RestClientException ::class )
134
- inline fun <reified T : Any > TestRestTemplate.postForObject (url : String , request : Any , vararg uriVariables : Any ): T ? =
156
+ inline fun <reified T : Any > TestRestTemplate.postForObject (url : String , request : Any? = null,
157
+ vararg uriVariables : Any ): T ? =
135
158
postForObject(url, request, T ::class .java, * uriVariables)
136
159
137
160
/* *
138
- * Extension for [TestRestTemplate.postForObject] avoiding specifying the type parameter
139
- * thanks to Kotlin reified type parameters.
161
+ * Extension for [TestRestTemplate.postForObject] providing a `postForObject<Foo>(...)`
162
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
163
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
164
+ * generic type arguments.
140
165
*
141
166
* @author Sebastien Deleuze
142
167
* @since 2.0.0
143
168
*/
144
169
@Throws(RestClientException ::class )
145
- inline fun <reified T : Any > TestRestTemplate.postForObject (url : String , request : Any , uriVariables : Map <String , * >): T ? =
170
+ inline fun <reified T : Any > TestRestTemplate.postForObject (url : String , request : Any? = null,
171
+ uriVariables : Map <String , * >): T ? =
146
172
postForObject(url, request, T ::class .java, uriVariables)
147
173
148
174
/* *
149
- * Extension for [TestRestTemplate.postForObject] avoiding specifying the type parameter
150
- * thanks to Kotlin reified type parameters.
175
+ * Extension for [TestRestTemplate.postForObject] providing a `postForObject<Foo>(...)`
176
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
177
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
178
+ * generic type arguments.
151
179
*
152
180
* @author Sebastien Deleuze
153
181
* @since 2.0.0
154
182
*/
155
183
@Throws(RestClientException ::class )
156
- inline fun <reified T : Any > TestRestTemplate.postForObject (url : URI , request : Any ): T ? =
184
+ inline fun <reified T : Any > TestRestTemplate.postForObject (url : URI , request : Any? = null ): T ? =
157
185
postForObject(url, request, T ::class .java)
158
186
159
187
/* *
160
- * Extension for [TestRestTemplate.postForEntity] avoiding specifying the type parameter
161
- * thanks to Kotlin reified type parameters.
188
+ * Extension for [TestRestTemplate.postForEntity] providing a `postForEntity<Foo>(...)`
189
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
190
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
191
+ * generic type arguments.
162
192
*
163
193
* @author Sebastien Deleuze
164
194
* @since 2.0.0
165
195
*/
166
196
@Throws(RestClientException ::class )
167
- inline fun <reified T : Any > TestRestTemplate.postForEntity (url : String , request : Any , vararg uriVariables : Any ): ResponseEntity <T > =
197
+ inline fun <reified T : Any > TestRestTemplate.postForEntity (url : String , request : Any? = null,
198
+ vararg uriVariables : Any ): ResponseEntity <T > =
168
199
postForEntity(url, request, T ::class .java, * uriVariables)
169
200
170
201
/* *
171
- * Extension for [TestRestTemplate.postForEntity] avoiding specifying the type parameter
172
- * thanks to Kotlin reified type parameters.
202
+ * Extension for [TestRestTemplate.postForEntity] providing a `postForEntity<Foo>(...)`
203
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
204
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
205
+ * generic type arguments.
173
206
*
174
207
* @author Sebastien Deleuze
175
208
* @since 2.0.0
176
209
*/
177
210
@Throws(RestClientException ::class )
178
- inline fun <reified T : Any > TestRestTemplate.postForEntity (url : String , request : Any , uriVariables : Map <String , * >): ResponseEntity <T > =
211
+ inline fun <reified T : Any > TestRestTemplate.postForEntity (url : String , request : Any? = null,
212
+ uriVariables : Map <String , * >): ResponseEntity <T > =
179
213
postForEntity(url, request, T ::class .java, uriVariables)
180
214
181
215
/* *
182
- * Extension for [TestRestTemplate.postForEntity] avoiding specifying the type parameter
183
- * thanks to Kotlin reified type parameters.
216
+ * Extension for [TestRestTemplate.postForEntity] providing a `postForEntity<Foo>(...)`
217
+ * variant leveraging Kotlin reified type parameters. Like the original Java method, this
218
+ * extension is subject to type erasure. Use [exchange] if you need to retain actual
219
+ * generic type arguments.
184
220
*
185
221
* @author Sebastien Deleuze
186
222
* @since 2.0.0
187
223
*/
188
224
@Throws(RestClientException ::class )
189
- inline fun <reified T : Any > TestRestTemplate.postForEntity (url : URI , request : Any ): ResponseEntity <T > =
225
+ inline fun <reified T : Any > TestRestTemplate.postForEntity (url : URI , request : Any? = null ): ResponseEntity <T > =
190
226
postForEntity(url, request, T ::class .java)
191
227
192
228
/* *
193
- * Extension for [TestRestTemplate.exchange] avoiding specifying the type parameter
194
- * thanks to Kotlin reified type parameters.
229
+ * Extension for [TestRestTemplate.exchange] providing an `exchange<Foo>(...)`
230
+ * variant leveraging Kotlin reified type parameters. This extension is not subject to
231
+ * type erasure and retains actual generic type arguments.
195
232
*
196
233
* @author Sebastien Deleuze
197
234
* @since 2.0.0
198
235
*/
199
236
@Throws(RestClientException ::class )
200
- inline fun <reified T : Any > TestRestTemplate.exchange (url : String , method : HttpMethod , requestEntity : HttpEntity <* >, vararg uriVariables : Any ): ResponseEntity <T > =
237
+ inline fun <reified T : Any > TestRestTemplate.exchange (url : String , method : HttpMethod ,
238
+ requestEntity : HttpEntity <* >? = null, vararg uriVariables : Any ): ResponseEntity <T > =
201
239
exchange(url, method, requestEntity, object : ParameterizedTypeReference <T >() {}, * uriVariables)
202
240
203
241
/* *
204
- * Extension for [TestRestTemplate.exchange] avoiding specifying the type parameter
205
- * thanks to Kotlin reified type parameters.
242
+ * Extension for [TestRestTemplate.exchange] providing an `exchange<Foo>(...)`
243
+ * variant leveraging Kotlin reified type parameters. This extension is not subject to
244
+ * type erasure and retains actual generic type arguments.
206
245
*
207
246
* @author Sebastien Deleuze
208
247
* @since 2.0.0
209
248
*/
210
249
@Throws(RestClientException ::class )
211
- inline fun <reified T : Any > TestRestTemplate.exchange (url : String , method : HttpMethod , requestEntity : HttpEntity <* >, uriVariables : Map <String , * >): ResponseEntity <T > =
250
+ inline fun <reified T : Any > TestRestTemplate.exchange (url : String , method : HttpMethod ,
251
+ requestEntity : HttpEntity <* >? = null, uriVariables : Map <String , * >): ResponseEntity <T > =
212
252
exchange(url, method, requestEntity, object : ParameterizedTypeReference <T >() {}, uriVariables)
213
253
214
254
/* *
215
- * Extension for [TestRestTemplate.exchange] avoiding specifying the type parameter
216
- * thanks to Kotlin reified type parameters.
255
+ * Extension for [TestRestTemplate.exchange] providing an `exchange<Foo>(...)`
256
+ * variant leveraging Kotlin reified type parameters. This extension is not subject to
257
+ * type erasure and retains actual generic type arguments.
217
258
*
218
259
* @author Sebastien Deleuze
219
260
* @since 2.0.0
220
261
*/
221
262
@Throws(RestClientException ::class )
222
- inline fun <reified T : Any > TestRestTemplate.exchange (url : URI , method : HttpMethod , requestEntity : HttpEntity <* >): ResponseEntity <T > =
263
+ inline fun <reified T : Any > TestRestTemplate.exchange (url : URI , method : HttpMethod ,
264
+ requestEntity : HttpEntity <* >? = null): ResponseEntity <T > =
223
265
exchange(url, method, requestEntity, object : ParameterizedTypeReference <T >() {})
224
266
225
267
/* *
226
- * Extension for [TestRestTemplate.exchange] avoiding specifying the type parameter
227
- * thanks to Kotlin reified type parameters.
268
+ * Extension for [TestRestTemplate.exchange] providing an `exchange<Foo>(...)`
269
+ * variant leveraging Kotlin reified type parameters. This extension is not subject to
270
+ * type erasure and retains actual generic type arguments.
228
271
*
229
272
* @author Sebastien Deleuze
230
273
* @since 2.0.0
0 commit comments