@@ -21,9 +21,7 @@ import org.springframework.http.HttpEntity
2121import org.springframework.http.HttpMethod
2222import org.springframework.http.RequestEntity
2323import org.springframework.http.ResponseEntity
24- import java.lang.Class
2524import java.net.URI
26- import kotlin.reflect.KClass
2725
2826/* *
2927 * Extension for [RestOperations.getForObject] providing a `getForObject<Foo>(...)`
@@ -36,8 +34,8 @@ import kotlin.reflect.KClass
3634 * @since 5.0
3735 */
3836@Throws(RestClientException ::class )
39- inline fun <reified T > RestOperations.getForObject (url : String , vararg uriVariables : Any? ): T =
40- getForObject(url, T ::class .java as Class < * > , * uriVariables) as T
37+ inline fun <reified T : Any > RestOperations.getForObject (url : String , vararg uriVariables : Any? ): T ? =
38+ getForObject(url, T ::class .java, * uriVariables)
4139
4240/* *
4341 * Extension for [RestOperations.getForObject] providing a `getForObject<Foo>(...)`
@@ -50,8 +48,8 @@ inline fun <reified T> RestOperations.getForObject(url: String, vararg uriVariab
5048 * @since 5.0
5149 */
5250@Throws(RestClientException ::class )
53- inline fun <reified T > RestOperations.getForObject (url : String , uriVariables : Map <String , Any ?>): T =
54- getForObject(url, T ::class .java as Class < * > , uriVariables) as T
51+ inline fun <reified T : Any > RestOperations.getForObject (url : String , uriVariables : Map <String , Any ?>): T ? =
52+ getForObject(url, T ::class .java, uriVariables)
5553
5654/* *
5755 * Extension for [RestOperations.getForObject] providing a `getForObject<Foo>(...)`
@@ -64,8 +62,8 @@ inline fun <reified T> RestOperations.getForObject(url: String, uriVariables: Ma
6462 * @since 5.0
6563 */
6664@Throws(RestClientException ::class )
67- inline fun <reified T > RestOperations.getForObject (url : URI ): T =
68- getForObject(url, T ::class .java as Class < * >) as T
65+ inline fun <reified T : Any > RestOperations.getForObject (url : URI ): T ? =
66+ getForObject(url, T ::class .java)
6967
7068/* *
7169 * Extension for [RestOperations.getForEntity] providing a `getForEntity<Foo>(...)`
@@ -118,9 +116,9 @@ inline fun <reified T: Any> RestOperations.getForEntity(url: String, uriVariable
118116 * @since 5.0.2
119117 */
120118@Throws(RestClientException ::class )
121- inline fun <reified T > RestOperations.patchForObject (url : String , request : Any? = null,
122- vararg uriVariables : Any? ): T =
123- patchForObject(url, request, T ::class .java as Class < * > , * uriVariables) as T
119+ inline fun <reified T : Any > RestOperations.patchForObject (url : String , request : Any? = null,
120+ vararg uriVariables : Any? ): T ? =
121+ patchForObject(url, request, T ::class .java, * uriVariables)
124122
125123/* *
126124 * Extension for [RestOperations.patchForObject] providing a `patchForObject<Foo>(...)`
@@ -132,9 +130,9 @@ inline fun <reified T> RestOperations.patchForObject(url: String, request: Any?
132130 * @since 5.0.2
133131 */
134132@Throws(RestClientException ::class )
135- inline fun <reified T > RestOperations.patchForObject (url : String , request : Any? = null,
136- uriVariables : Map <String , * >): T =
137- patchForObject(url, request, T ::class .java as Class < * > , uriVariables) as T
133+ inline fun <reified T : Any > RestOperations.patchForObject (url : String , request : Any? = null,
134+ uriVariables : Map <String , * >): T ? =
135+ patchForObject(url, request, T ::class .java, uriVariables)
138136
139137/* *
140138 * Extension for [RestOperations.patchForObject] providing a `patchForObject<Foo>(...)`
@@ -146,8 +144,8 @@ inline fun <reified T> RestOperations.patchForObject(url: String, request: Any?
146144 * @since 5.0.2
147145 */
148146@Throws(RestClientException ::class )
149- inline fun <reified T > RestOperations.patchForObject (url : URI , request : Any? = null): T =
150- patchForObject(url, request, T ::class .java as Class < * >) as T
147+ inline fun <reified T : Any > RestOperations.patchForObject (url : URI , request : Any? = null): T ? =
148+ patchForObject(url, request, T ::class .java)
151149
152150/* *
153151 * Extension for [RestOperations.postForObject] providing a `postForObject<Foo>(...)`
@@ -160,9 +158,9 @@ inline fun <reified T> RestOperations.patchForObject(url: URI, request: Any? = n
160158 * @since 5.0
161159 */
162160@Throws(RestClientException ::class )
163- inline fun <reified T > RestOperations.postForObject (url : String , request : Any? = null,
164- vararg uriVariables : Any? ): T =
165- postForObject(url, request, T ::class .java as Class < * > , * uriVariables) as T
161+ inline fun <reified T : Any > RestOperations.postForObject (url : String , request : Any? = null,
162+ vararg uriVariables : Any? ): T ? =
163+ postForObject(url, request, T ::class .java, * uriVariables)
166164
167165/* *
168166 * Extension for [RestOperations.postForObject] providing a `postForObject<Foo>(...)`
@@ -175,9 +173,9 @@ inline fun <reified T> RestOperations.postForObject(url: String, request: Any? =
175173 * @since 5.0
176174 */
177175@Throws(RestClientException ::class )
178- inline fun <reified T > RestOperations.postForObject (url : String , request : Any? = null,
179- uriVariables : Map <String , * >): T =
180- postForObject(url, request, T ::class .java as Class < * > , uriVariables) as T
176+ inline fun <reified T : Any > RestOperations.postForObject (url : String , request : Any? = null,
177+ uriVariables : Map <String , * >): T ? =
178+ postForObject(url, request, T ::class .java, uriVariables)
181179
182180/* *
183181 * Extension for [RestOperations.postForObject] providing a `postForObject<Foo>(...)`
@@ -190,8 +188,8 @@ inline fun <reified T> RestOperations.postForObject(url: String, request: Any? =
190188 * @since 5.0
191189 */
192190@Throws(RestClientException ::class )
193- inline fun <reified T > RestOperations.postForObject (url : URI , request : Any? = null): T =
194- postForObject(url, request, T ::class .java as Class < * >) as T
191+ inline fun <reified T : Any > RestOperations.postForObject (url : URI , request : Any? = null): T ? =
192+ postForObject(url, request, T ::class .java)
195193
196194/* *
197195 * Extension for [RestOperations.postForEntity] providing a `postForEntity<Foo>(...)`
0 commit comments