Add missing RestOperations extensions

Issue: SPR-16229
This commit is contained in:
sdeleuze
2017-11-23 22:09:34 +01:00
parent 01a82b5291
commit 3b96690e69
2 changed files with 116 additions and 0 deletions

View File

@@ -59,6 +59,17 @@ inline fun <reified T: Any> RestOperations.getForObject(url: String, uriVariable
inline fun <reified T: Any> RestOperations.getForObject(url: URI): T? =
getForObject(url, T::class.java)
/**
* Extension for [RestOperations.getForEntity] avoiding requiring the type parameter
* thanks to Kotlin reified type parameters.
*
* @author Sebastien Deleuze
* @since 5.0.2
*/
@Throws(RestClientException::class)
inline fun <reified T: Any> RestOperations.getForEntity(url: URI): ResponseEntity<T> =
getForEntity(url, T::class.java)
/**
* Extension for [RestOperations.getForEntity] avoiding requiring the type parameter
* thanks to Kotlin reified type parameters.
@@ -71,6 +82,50 @@ inline fun <reified T: Any> RestOperations.getForObject(url: URI): T? =
inline fun <reified T: Any> RestOperations.getForEntity(url: String, vararg uriVariables: Any): ResponseEntity<T> =
getForEntity(url, T::class.java, *uriVariables)
/**
* Extension for [RestOperations.getForEntity] avoiding requiring the type parameter
* thanks to Kotlin reified type parameters.
*
* @author Sebastien Deleuze
* @since 5.0.2
*/
@Throws(RestClientException::class)
inline fun <reified T: Any> RestOperations.getForEntity(url: String, uriVariables: Map<String, *>): ResponseEntity<T> =
getForEntity(url, T::class.java, uriVariables)
/**
* Extension for [RestOperations.patchForObject] avoiding specifying the type parameter
* thanks to Kotlin reified type parameters.
*
* @author Sebastien Deleuze
* @since 5.0.2
*/
@Throws(RestClientException::class)
inline fun <reified T: Any> RestOperations.patchForObject(url: String, request: Any, vararg uriVariables: Any): T? =
patchForObject(url, request, T::class.java, *uriVariables)
/**
* Extension for [RestOperations.patchForObject] avoiding specifying the type parameter
* thanks to Kotlin reified type parameters.
*
* @author Sebastien Deleuze
* @since 5.0.2
*/
@Throws(RestClientException::class)
inline fun <reified T: Any> RestOperations.patchForObject(url: String, request: Any, uriVariables: Map<String, *>): T? =
patchForObject(url, request, T::class.java, uriVariables)
/**
* Extension for [RestOperations.patchForObject] avoiding specifying the type parameter
* thanks to Kotlin reified type parameters.
*
* @author Sebastien Deleuze
* @since 5.0.2
*/
@Throws(RestClientException::class)
inline fun <reified T: Any> RestOperations.patchForObject(url: URI, request: Any): T? =
patchForObject(url, request, T::class.java)
/**
* Extension for [RestOperations.postForObject] avoiding specifying the type parameter
* thanks to Kotlin reified type parameters.