Remove KClass based Kotlin extensions
Issue: SPR-15660
This commit is contained in:
@@ -3,7 +3,6 @@ package org.springframework.web.reactive.function
|
||||
import org.springframework.http.ReactiveHttpInputMessage
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* Function for providing a `bodyToMono()` alternative to `BodyExtractors.toMono(Foo::class.java)`.
|
||||
@@ -15,16 +14,6 @@ import kotlin.reflect.KClass
|
||||
inline fun <reified T : Any> bodyToMono(): BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
||||
BodyExtractors.toMono(T::class.java)
|
||||
|
||||
/**
|
||||
* Function for providing a `bodyToMono(Foo::class)` alternative to `BodyExtractors.toMono(Foo::class.java)`.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
* @see [KT-11968](https://youtrack.jetbrains.com/issue/KT-11968)
|
||||
*/
|
||||
fun <T : Any> bodyToMono(elementClass: KClass<T>): BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
||||
BodyExtractors.toMono(elementClass.java)
|
||||
|
||||
/**
|
||||
* Function for providing a `bodyToFlux()` alternative to `BodyExtractors.toFlux(Foo::class.java)`.
|
||||
*
|
||||
@@ -35,12 +24,3 @@ fun <T : Any> bodyToMono(elementClass: KClass<T>): BodyExtractor<Mono<T>, Reacti
|
||||
inline fun <reified T : Any> bodyToFlux(): BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
||||
BodyExtractors.toFlux(T::class.java)
|
||||
|
||||
/**
|
||||
* Function for providing a `bodyToFlux(Foo::class)` alternative to `BodyExtractors.toFlux(Foo::class.java)`.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
* @see [KT-11968](https://youtrack.jetbrains.com/issue/KT-11968)
|
||||
*/
|
||||
fun <T : Any> bodyToFlux(elementClass: KClass<T>): BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
||||
BodyExtractors.toFlux(elementClass.java)
|
||||
|
||||
@@ -2,17 +2,8 @@ package org.springframework.web.reactive.function.client
|
||||
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
/**
|
||||
* Extension for [ClientResponse.bodyToMono] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> ClientResponse.bodyToMono(type: KClass<T>): Mono<T> = bodyToMono(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [ClientResponse.bodyToMono] providing a `bodyToMono<Foo>()` variant.
|
||||
*
|
||||
@@ -21,15 +12,6 @@ fun <T : Any> ClientResponse.bodyToMono(type: KClass<T>): Mono<T> = bodyToMono(t
|
||||
*/
|
||||
inline fun <reified T : Any> ClientResponse.bodyToMono(): Mono<T> = bodyToMono(T::class.java)
|
||||
|
||||
|
||||
/**
|
||||
* Extension for [ClientResponse.bodyToFlux] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> ClientResponse.bodyToFlux(type: KClass<T>): Flux<T> = bodyToFlux(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [ClientResponse.bodyToFlux] providing a `bodyToFlux<Foo>()` variant.
|
||||
*
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.reactivestreams.Publisher
|
||||
import org.springframework.http.ResponseEntity
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
/**
|
||||
* Extension for [WebClient.RequestBodySpec.body] providing a variant without explicit class
|
||||
@@ -33,14 +33,6 @@ import kotlin.reflect.KClass
|
||||
inline fun <reified T : Any, S : Publisher<T>> WebClient.RequestBodySpec.body(publisher: S): WebClient.RequestHeadersSpec<*>
|
||||
= body(publisher, T::class.java)
|
||||
|
||||
/**
|
||||
* Extension for [WebClient.ResponseSpec.bodyToMono] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> WebClient.ResponseSpec.bodyToMono(type: KClass<T>): Mono<T> = bodyToMono(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [WebClient.ResponseSpec.bodyToMono] providing a `bodyToMono<Foo>()` variant.
|
||||
*
|
||||
@@ -50,14 +42,6 @@ fun <T : Any> WebClient.ResponseSpec.bodyToMono(type: KClass<T>): Mono<T> = body
|
||||
inline fun <reified T : Any> WebClient.ResponseSpec.bodyToMono(): Mono<T> = bodyToMono(T::class.java)
|
||||
|
||||
|
||||
/**
|
||||
* Extension for [WebClient.ResponseSpec.bodyToFlux] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> WebClient.ResponseSpec.bodyToFlux(type: KClass<T>): Flux<T> = bodyToFlux(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [WebClient.ResponseSpec.bodyToFlux] providing a `bodyToFlux<Foo>()` variant.
|
||||
*
|
||||
@@ -66,14 +50,6 @@ fun <T : Any> WebClient.ResponseSpec.bodyToFlux(type: KClass<T>): Flux<T> = body
|
||||
*/
|
||||
inline fun <reified T : Any> WebClient.ResponseSpec.bodyToFlux(): Flux<T> = bodyToFlux(T::class.java)
|
||||
|
||||
/**
|
||||
* Extension for [WebClient.ResponseSpec.toEntity] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> WebClient.ResponseSpec.toEntity(type: KClass<T>): Mono<ResponseEntity<T>> = toEntity(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [WebClient.ResponseSpec.toEntity] providing a `bodyToEntity<Foo>()` variant.
|
||||
*
|
||||
@@ -82,14 +58,6 @@ fun <T : Any> WebClient.ResponseSpec.toEntity(type: KClass<T>): Mono<ResponseEnt
|
||||
*/
|
||||
inline fun <reified T : Any> WebClient.ResponseSpec.toEntity(): Mono<ResponseEntity<T>> = toEntity(T::class.java)
|
||||
|
||||
/**
|
||||
* Extension for [WebClient.ResponseSpec.toEntityList] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> WebClient.ResponseSpec.toEntityList(type: KClass<T>): Mono<ResponseEntity<List<T>>> = toEntityList(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [WebClient.ResponseSpec.toEntityList] providing a `bodyToEntityList<Foo>()` variant.
|
||||
*
|
||||
|
||||
@@ -2,17 +2,8 @@ package org.springframework.web.reactive.function.server
|
||||
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
/**
|
||||
* Extension for [ServerRequest.bodyToMono] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> ServerRequest.bodyToMono(type: KClass<T>): Mono<T> = bodyToMono(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [ServerRequest.bodyToMono] providing a `bodyToMono<Foo>()` variant.
|
||||
*
|
||||
@@ -21,14 +12,6 @@ fun <T : Any> ServerRequest.bodyToMono(type: KClass<T>): Mono<T> = bodyToMono(ty
|
||||
*/
|
||||
inline fun <reified T : Any> ServerRequest.bodyToMono(): Mono<T> = bodyToMono(T::class.java)
|
||||
|
||||
/**
|
||||
* Extension for [ServerRequest.bodyToFlux] providing a [KClass] based variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> ServerRequest.bodyToFlux(type: KClass<T>): Flux<T> = bodyToFlux(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [ServerRequest.bodyToFlux] providing a `bodyToFlux<Foo>()` variant.
|
||||
*
|
||||
|
||||
@@ -14,21 +14,11 @@ import org.mockito.junit.MockitoJUnitRunner
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class BodyExtractorsExtensionsTests {
|
||||
|
||||
@Test
|
||||
fun `bodyToMono with KClass`() {
|
||||
assertNotNull(bodyToMono(Foo::class))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToMono with reified type parameter`() {
|
||||
assertNotNull(bodyToMono<Foo>())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToFlux with KClass`() {
|
||||
assertNotNull(bodyToFlux(Foo::class))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToFlux with reified type parameter`() {
|
||||
assertNotNull(bodyToFlux<Foo>())
|
||||
|
||||
@@ -18,24 +18,12 @@ class ClientResponseExtensionsTests {
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var response: ClientResponse
|
||||
|
||||
@Test
|
||||
fun `bodyToMono with KClass`() {
|
||||
response.bodyToMono(Foo::class)
|
||||
verify(response, times(1)).bodyToMono(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToMono with reified type parameters`() {
|
||||
response.bodyToMono<Foo>()
|
||||
verify(response, times(1)).bodyToMono(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToFlux with KClass`() {
|
||||
response.bodyToFlux(Foo::class)
|
||||
verify(response, times(1)).bodyToFlux(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToFlux with reified type parameters`() {
|
||||
response.bodyToFlux<Foo>()
|
||||
|
||||
@@ -31,48 +31,24 @@ class WebClientExtensionsTests {
|
||||
verify(requestBodySpec, times(1)).body(body, Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#bodyToMono with KClass`() {
|
||||
responseSpec.bodyToMono(Foo::class)
|
||||
verify(responseSpec, times(1)).bodyToMono(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#bodyToMono with reified type parameters`() {
|
||||
responseSpec.bodyToMono<Foo>()
|
||||
verify(responseSpec, times(1)).bodyToMono(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#bodyToFlux with KClass`() {
|
||||
responseSpec.bodyToFlux(Foo::class)
|
||||
verify(responseSpec, times(1)).bodyToFlux(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#bodyToFlux with reified type parameters`() {
|
||||
responseSpec.bodyToFlux<Foo>()
|
||||
verify(responseSpec, times(1)).bodyToFlux(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#toEntity with KClass`() {
|
||||
responseSpec.toEntity(Foo::class)
|
||||
verify(responseSpec, times(1)).toEntity(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#toEntity with reified type parameters`() {
|
||||
responseSpec.toEntity<Foo>()
|
||||
verify(responseSpec, times(1)).toEntity(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#toEntityList with KClass`() {
|
||||
responseSpec.toEntityList(Foo::class)
|
||||
verify(responseSpec, times(1)).toEntityList(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ResponseSpec#toEntityList with reified type parameters`() {
|
||||
responseSpec.toEntityList<Foo>()
|
||||
|
||||
@@ -21,24 +21,12 @@ class ServerRequestExtensionsTests {
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var request: ServerRequest
|
||||
|
||||
@Test
|
||||
fun `bodyToMono with KClass`() {
|
||||
request.bodyToMono(Foo::class)
|
||||
verify(request, times(1)).bodyToMono(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToMono with reified type parameters`() {
|
||||
request.bodyToMono<Foo>()
|
||||
verify(request, times(1)).bodyToMono(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToFlux with KClass`() {
|
||||
request.bodyToFlux(Foo::class)
|
||||
verify(request, times(1)).bodyToFlux(Foo::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `bodyToFlux with reified type parameters`() {
|
||||
request.bodyToFlux<Foo>()
|
||||
|
||||
Reference in New Issue
Block a user