From b04b41b93b1bad9b80044a10c71de691be591d36 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Wed, 11 Jan 2017 08:59:10 +0100 Subject: [PATCH] Add bodyToMono/Flux() Kotlin extensions Issue: SPR-15128 --- .../client/ClientResponseExtensions.kt | 18 ++++++++++++++++++ .../function/server/ServerRequestExtensions.kt | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/spring-web-reactive/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt b/spring-web-reactive/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt index c22f7391923..b603336ba31 100644 --- a/spring-web-reactive/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt +++ b/spring-web-reactive/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt @@ -13,6 +13,15 @@ import kotlin.reflect.KClass */ fun ClientResponse.bodyToMono(type: KClass) : Mono = bodyToMono(type.java) +/** + * Extension for [ClientResponse.bodyToMono] providing a `bodyToMono()` variant. + * + * @author Sebastien Deleuze + * @since 5.0 + */ +inline fun ClientResponse.bodyToMono() = bodyToMono(T::class.java) + + /** * Extension for [ClientResponse.bodyToFlux] providing a [KClass] based variant. * @@ -21,4 +30,13 @@ fun ClientResponse.bodyToMono(type: KClass) : Mono = bodyToMono( */ fun ClientResponse.bodyToFlux(type: KClass) : Flux = bodyToFlux(type.java) +/** + * Extension for [ClientResponse.bodyToFlux] providing a `bodyToFlux()` variant. + * + * @author Sebastien Deleuze + * @since 5.0 + */ +inline fun ClientResponse.bodyToFlux() = bodyToFlux(T::class.java) + + diff --git a/spring-web-reactive/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt b/spring-web-reactive/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt index c9dd5c5ae38..dc76c673956 100644 --- a/spring-web-reactive/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt +++ b/spring-web-reactive/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt @@ -11,6 +11,14 @@ import kotlin.reflect.KClass */ fun ServerRequest.bodyToMono(type: KClass) = bodyToMono(type.java) +/** + * Extension for [ServerRequest.bodyToMono] providing a `bodyToMono()` variant. + * + * @author Sebastien Deleuze + * @since 5.0 + */ +inline fun ServerRequest.bodyToMono() = bodyToMono(T::class.java) + /** * Extension for [ServerRequest.bodyToFlux] providing a [KClass] based variant. * @@ -18,3 +26,11 @@ fun ServerRequest.bodyToMono(type: KClass) = bodyToMono(type.java) * @since 5.0 */ fun ServerRequest.bodyToFlux(type: KClass) = bodyToFlux(type.java) + +/** + * Extension for [ServerRequest.bodyToFlux] providing a `bodyToFlux()` variant. + * + * @author Sebastien Deleuze + * @since 5.0 + */ +inline fun ServerRequest.bodyToFlux() = bodyToFlux(T::class.java)