diff --git a/spring-beans/src/main/kotlin/org/springframework/beans/factory/BeanFactoryExtensions.kt b/spring-beans/src/main/kotlin/org/springframework/beans/factory/BeanFactoryExtensions.kt index 0b3c9b435ca..ce551d79094 100644 --- a/spring-beans/src/main/kotlin/org/springframework/beans/factory/BeanFactoryExtensions.kt +++ b/spring-beans/src/main/kotlin/org/springframework/beans/factory/BeanFactoryExtensions.kt @@ -1,15 +1,5 @@ package org.springframework.beans.factory -import kotlin.reflect.KClass - - -/** - * Extension for [BeanFactory.getBean] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun BeanFactory.getBean(requiredType: KClass): T = getBean(requiredType.java) /** * Extension for [BeanFactory.getBean] providing a `getBean()` variant. @@ -30,16 +20,6 @@ inline fun BeanFactory.getBean(): T = getBean(T::class.java) inline fun BeanFactory.getBean(name: String): T = getBean(name, T::class.java) -/** - * Extension for [BeanFactory.getBean] providing a [KClass] based variant. - * - * @see BeanFactory.getBean(Class, Object...) - * @author Sebastien Deleuze - * @since 5.0 - */ -fun BeanFactory.getBean(requiredType: KClass, vararg args:Any): T = - getBean(requiredType.java, *args) - /** * Extension for [BeanFactory.getBean] providing a `getBean(arg1, arg2)` variant. * diff --git a/spring-beans/src/main/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensions.kt b/spring-beans/src/main/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensions.kt index cf7f418a433..9c2dded343e 100644 --- a/spring-beans/src/main/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensions.kt +++ b/spring-beans/src/main/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensions.kt @@ -1,18 +1,5 @@ package org.springframework.beans.factory -import kotlin.reflect.KClass - - -/** - * Extension for [ListableBeanFactory.getBeanNamesForType] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun ListableBeanFactory.getBeanNamesForType(type: KClass, - includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Array = - getBeanNamesForType(type.java, includeNonSingletons, allowEagerInit) - /** * Extension for [ListableBeanFactory.getBeanNamesForType] providing a `getBeanNamesForType()` variant. * @@ -22,15 +9,6 @@ fun ListableBeanFactory.getBeanNamesForType(type: KClass, inline fun ListableBeanFactory.getBeanNamesForType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Array = getBeanNamesForType(T::class.java, includeNonSingletons, allowEagerInit) -/** - * Extension for [ListableBeanFactory.getBeansOfType] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun ListableBeanFactory.getBeansOfType(type: KClass, includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Map = - getBeansOfType(type.java, includeNonSingletons, allowEagerInit) - /** * Extension for [ListableBeanFactory.getBeansOfType] providing a `getBeansOfType()` variant. * @@ -40,15 +18,6 @@ fun ListableBeanFactory.getBeansOfType(type: KClass, includeNonSing inline fun ListableBeanFactory.getBeansOfType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Map = getBeansOfType(T::class.java, includeNonSingletons, allowEagerInit) -/** - * Extension for [ListableBeanFactory.getBeanNamesForAnnotation] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun ListableBeanFactory.getBeanNamesForAnnotation(type: KClass): Array = - getBeanNamesForAnnotation(type.java) - /** * Extension for [ListableBeanFactory.getBeanNamesForAnnotation] providing a `getBeansOfType()` variant. * @@ -58,15 +27,6 @@ fun ListableBeanFactory.getBeanNamesForAnnotation(type: KClass< inline fun ListableBeanFactory.getBeanNamesForAnnotation(): Array = getBeanNamesForAnnotation(T::class.java) -/** - * Extension for [ListableBeanFactory.getBeansWithAnnotation] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun ListableBeanFactory.getBeansWithAnnotation(type: KClass): MutableMap = - getBeansWithAnnotation(type.java) - /** * Extension for [ListableBeanFactory.getBeansWithAnnotation] providing a `getBeansWithAnnotation()` variant. * @@ -76,15 +36,6 @@ fun ListableBeanFactory.getBeansWithAnnotation(type: KClass) inline fun ListableBeanFactory.getBeansWithAnnotation(): MutableMap = getBeansWithAnnotation(T::class.java) -/** - * Extension for [ListableBeanFactory.findAnnotationOnBean] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun ListableBeanFactory.findAnnotationOnBean(beanName:String, type: KClass): Annotation? = - findAnnotationOnBean(beanName, type.java) - /** * Extension for [ListableBeanFactory.findAnnotationOnBean] providing a `findAnnotationOnBean("foo")` variant. * diff --git a/spring-beans/src/test/kotlin/org/springframework/beans/factory/BeanFactoryExtensionsTests.kt b/spring-beans/src/test/kotlin/org/springframework/beans/factory/BeanFactoryExtensionsTests.kt index a3f81956ca5..d8036432def 100644 --- a/spring-beans/src/test/kotlin/org/springframework/beans/factory/BeanFactoryExtensionsTests.kt +++ b/spring-beans/src/test/kotlin/org/springframework/beans/factory/BeanFactoryExtensionsTests.kt @@ -18,12 +18,6 @@ class BeanFactoryExtensionsTests { @Mock(answer = Answers.RETURNS_MOCKS) lateinit var bf: BeanFactory - @Test - fun `getBean with KClass`() { - bf.getBean(Foo::class) - verify(bf, times(1)).getBean(Foo::class.java) - } - @Test fun `getBean with reified type parameters`() { bf.getBean() @@ -37,14 +31,6 @@ class BeanFactoryExtensionsTests { verify(bf, times(1)).getBean(name, Foo::class.java) } - @Test - fun `getBean with KClass and varargs`() { - val arg1 = "arg1" - val arg2 = "arg2" - bf.getBean(Foo::class, arg1, arg2) - verify(bf, times(1)).getBean(Foo::class.java, arg1, arg2) - } - @Test fun `getBean with reified type parameters and varargs`() { val arg1 = "arg1" diff --git a/spring-beans/src/test/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensionsTests.kt b/spring-beans/src/test/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensionsTests.kt index fd7963e4d47..37a9fd293ec 100644 --- a/spring-beans/src/test/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensionsTests.kt +++ b/spring-beans/src/test/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensionsTests.kt @@ -18,24 +18,6 @@ class ListableBeanFactoryExtensionsTests { @Mock(answer = Answers.RETURNS_MOCKS) lateinit var lbf: ListableBeanFactory - @Test - fun `getBeanNamesForType with KClass`() { - lbf.getBeanNamesForType(Foo::class) - verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, true , true) - } - - @Test - fun `getBeanNamesForType with KClass and Boolean`() { - lbf.getBeanNamesForType(Foo::class, false) - verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , true) - } - - @Test - fun `getBeanNamesForType with KClass, Boolean and Boolean`() { - lbf.getBeanNamesForType(Foo::class, false, false) - verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , false) - } - @Test fun `getBeanNamesForType with reified type parameters`() { lbf.getBeanNamesForType() @@ -54,24 +36,6 @@ class ListableBeanFactoryExtensionsTests { verify(lbf, times(1)).getBeanNamesForType(Foo::class.java, false , false) } - @Test - fun `getBeansOfType with KClass`() { - lbf.getBeansOfType(Foo::class) - verify(lbf, times(1)).getBeansOfType(Foo::class.java, true , true) - } - - @Test - fun `getBeansOfType with KClass and Boolean`() { - lbf.getBeansOfType(Foo::class, false) - verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , true) - } - - @Test - fun `getBeansOfType with KClass, Boolean and Boolean`() { - lbf.getBeansOfType(Foo::class, false, false) - verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , false) - } - @Test fun `getBeansOfType with reified type parameters`() { lbf.getBeansOfType() @@ -90,37 +54,18 @@ class ListableBeanFactoryExtensionsTests { verify(lbf, times(1)).getBeansOfType(Foo::class.java, false , false) } - @Test - fun `getBeanNamesForAnnotation with KClass`() { - lbf.getBeanNamesForAnnotation(Bar::class) - verify(lbf, times(1)).getBeanNamesForAnnotation(Bar::class.java) - } - @Test fun `getBeanNamesForAnnotation with reified type parameters`() { lbf.getBeanNamesForAnnotation() verify(lbf, times(1)).getBeanNamesForAnnotation(Bar::class.java) } - @Test - fun `getBeansWithAnnotation with KClass`() { - lbf.getBeansWithAnnotation(Bar::class) - verify(lbf, times(1)).getBeansWithAnnotation(Bar::class.java) - } - @Test fun `getBeansWithAnnotation with reified type parameters`() { lbf.getBeansWithAnnotation() verify(lbf, times(1)).getBeansWithAnnotation(Bar::class.java) } - @Test - fun `findAnnotationOnBean with String and KClass`() { - val name = "bar" - lbf.findAnnotationOnBean(name, Bar::class) - verify(lbf, times(1)).findAnnotationOnBean(name, Bar::class.java) - } - @Test fun `findAnnotationOnBean with String and reified type parameters`() { val name = "bar" diff --git a/spring-context/src/main/kotlin/org/springframework/context/support/GenericApplicationContextExtensions.kt b/spring-context/src/main/kotlin/org/springframework/context/support/GenericApplicationContextExtensions.kt index 59acb1fae69..144971de37e 100644 --- a/spring-context/src/main/kotlin/org/springframework/context/support/GenericApplicationContextExtensions.kt +++ b/spring-context/src/main/kotlin/org/springframework/context/support/GenericApplicationContextExtensions.kt @@ -3,19 +3,8 @@ package org.springframework.context.support import org.springframework.beans.factory.config.BeanDefinitionCustomizer import org.springframework.context.ApplicationContext import java.util.function.Supplier -import kotlin.reflect.KClass -/** - * Extension for [GenericApplicationContext.registerBean] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun GenericApplicationContext.registerBean(beanClass: KClass, vararg customizers: BeanDefinitionCustomizer) { - registerBean(beanClass.java, *customizers) -} - /** * Extension for [GenericApplicationContext.registerBean] providing a `registerBean()` variant. * @@ -26,16 +15,6 @@ inline fun GenericApplicationContext.registerBean(vararg custo registerBean(T::class.java, *customizers) } -/** - * Extension for [GenericApplicationContext.registerBean] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun GenericApplicationContext.registerBean(beanName: String, beanClass: KClass, vararg customizers: BeanDefinitionCustomizer) { - registerBean(beanName, beanClass.java, *customizers) -} - /** * Extension for [GenericApplicationContext.registerBean] providing a `registerBean("foo")` variant. * diff --git a/spring-context/src/test/kotlin/org/springframework/context/support/GenericApplicationContextExtensionsTests.kt b/spring-context/src/test/kotlin/org/springframework/context/support/GenericApplicationContextExtensionsTests.kt index e3d138744ce..6c8e5a18ecc 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/support/GenericApplicationContextExtensionsTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/support/GenericApplicationContextExtensionsTests.kt @@ -14,15 +14,15 @@ class GenericApplicationContextExtensionsTests { @Test fun registerBeanWithClass() { val context = GenericApplicationContext() - context.registerBean(BeanA::class) + context.registerBean() context.refresh() - assertNotNull(context.getBean(BeanA::class)) + assertNotNull(context.getBean()) } @Test fun registerBeanWithNameAndClass() { val context = GenericApplicationContext() - context.registerBean("a", BeanA::class) + context.registerBean("a") context.refresh() assertNotNull(context.getBean("a")) } @@ -32,7 +32,7 @@ class GenericApplicationContextExtensionsTests { val context = GenericApplicationContext() context.registerBean { BeanA() } context.refresh() - assertNotNull(context.getBean(BeanA::class)) + assertNotNull(context.getBean()) } @Test @@ -46,34 +46,23 @@ class GenericApplicationContextExtensionsTests { @Test fun registerBeanWithFunction() { val context = GenericApplicationContext() - context.registerBean(BeanA::class) - context.registerBean { BeanB(it.getBean(BeanA::class)) } + context.registerBean() + context.registerBean { BeanB(it.getBean()) } context.refresh() - assertNotNull(context.getBean(BeanA::class)) - assertNotNull(context.getBean(BeanB::class)) + assertNotNull(context.getBean()) + assertNotNull(context.getBean()) } @Test fun registerBeanWithNameAndFunction() { val context = GenericApplicationContext() - context.registerBean("a", BeanA::class) - context.registerBean("b") { BeanB(it.getBean(BeanA::class)) } + context.registerBean("a") + context.registerBean("b") { BeanB(it.getBean()) } context.refresh() assertNotNull(context.getBean("a")) assertNotNull(context.getBean("b")) } - @Test - fun registerBeanWithGradleStyleApi() { - val context = GenericApplicationContext { - registerBean() - registerBean { BeanB(it.getBean()) } - } - context.refresh() - assertNotNull(context.getBean()) - assertNotNull(context.getBean()) - } - class BeanA class BeanB(val a: BeanA) diff --git a/spring-jdbc/src/main/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensions.kt b/spring-jdbc/src/main/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensions.kt index 3c053797ada..34b4c248e1f 100644 --- a/spring-jdbc/src/main/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensions.kt +++ b/spring-jdbc/src/main/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensions.kt @@ -17,17 +17,8 @@ package org.springframework.jdbc.core import java.sql.ResultSet -import kotlin.reflect.KClass -/** - * Extension for [JdbcOperations.queryForObject] providing a [KClass] based variant - * - * @author Mario Arias - * @since 5.0 - */ -fun JdbcOperations.queryForObject(sql: String, elementType: KClass): T? = queryForObject(sql, elementType.java) - /** * Extension for [JdbcOperations.queryForObject] providing a `queryForObject("...")` variant * @@ -45,15 +36,6 @@ inline fun JdbcOperations.queryForObject(sql: String): T? = qu fun JdbcOperations.queryForObject(sql: String, vararg args: Any, function: (ResultSet, Int) -> T): T = queryForObject(sql, RowMapper { resultSet, i -> function(resultSet, i) }, *args) -/** - * Extension for [JdbcOperations.queryForObject] providing a [KClass] based variant - * - * @author Mario Arias - * @since 5.0 - */ -fun JdbcOperations.queryForObject(sql: String, args: Array, argTypes: IntArray, requiredType: KClass): T? = - queryForObject(sql, args, argTypes, requiredType.java) - /** * Extension for [JdbcOperations.queryForObject] providing a `queryForObject("...", arrayOf(arg1, argN), intArray(type1, typeN))` variant * @@ -63,15 +45,6 @@ fun JdbcOperations.queryForObject(sql: String, args: Array, a inline fun JdbcOperations.queryForObject(sql: String, args: Array, argTypes: IntArray): T? = queryForObject(sql, args, argTypes, T::class.java) -/** - * Extension for [JdbcOperations.queryForObject] providing a [KClass] based variant - * - * @author Mario Arias - * @since 5.0 - */ -fun JdbcOperations.queryForObject(sql: String, args: Array, requiredType: KClass): T? = - queryForObject(sql, args, requiredType.java) - /** * Extension for [JdbcOperations.queryForObject] providing a `queryForObject("...", arrayOf(arg1, argN))` variant * @@ -81,15 +54,6 @@ fun JdbcOperations.queryForObject(sql: String, args: Array, r inline fun JdbcOperations.queryForObject(sql: String, args: Array): T? = queryForObject(sql, args, T::class.java) -/** - * Extension for [JdbcOperations.queryForObject] providing a [KClass] based variant - * - * @author Mario Arias - * @since 5.0 - */ -fun JdbcOperations.queryForObject(sql: String, requiredType: KClass, vararg args: Any): T? = - queryForObject(sql, requiredType.java, *args) - /** * Extension for [JdbcOperations.queryForList] providing a `queryForList("...")` variant. diff --git a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt index 28fb25d2bd1..c7c9e05e6b1 100644 --- a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt +++ b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt @@ -38,14 +38,6 @@ class JdbcOperationsExtensionsTests { @Mock(answer = Answers.RETURNS_MOCKS) lateinit var template: JdbcTemplate - @Test - fun `queryForObject with KClass`() { - val sql = "select age from customer where id = 3" - val requiredType = Int::class - template.queryForObject(sql, requiredType) - verify(template, times(1)).queryForObject(sql, requiredType) - } - @Test fun `queryForObject with reified type parameters`() { val sql = "select age from customer where id = 3" @@ -60,16 +52,6 @@ class JdbcOperationsExtensionsTests { verify(template, times(1)).queryForObject(eq(sql), any>(), eq(3)) } - @Test - fun `queryForObject with argTypes`() { - val sql = "select age from customer where id = ?" - val args = arrayOf(3) - val argTypes = intArrayOf(JDBCType.INTEGER.vendorTypeNumber) - val requiredType = Int::class - template.queryForObject(sql, args, argTypes, requiredType) - verify(template, times(1)).queryForObject(sql, args, argTypes, requiredType) - } - @Test fun `queryForObject with reified type parameters and argTypes`() { val sql = "select age from customer where id = ?" @@ -79,14 +61,6 @@ class JdbcOperationsExtensionsTests { verify(template, times(1)).queryForObject(sql, args, argTypes, Integer::class.java) } - @Test - fun `queryForObject with args`() { - val sql = "select age from customer where id = ?" - val args = arrayOf(3) - template.queryForObject(sql, args, Int::class) - verify(template, times(1)).queryForObject(sql, args, Int::class.java) - } - @Test fun `queryForObject with reified type parameters and args`() { val sql = "select age from customer where id = ?" @@ -95,13 +69,6 @@ class JdbcOperationsExtensionsTests { verify(template, times(1)).queryForObject(sql, args, Integer::class.java) } - @Test - fun `queryForObject with varargs`() { - val sql = "select age from customer where id = ?" - template.queryForObject(sql, Int::class, 3) - verify(template, times(1)).queryForObject(sql, Int::class.java, 3) - } - @Test fun `queryForList with reified type parameters`() { val sql = "select age from customer where id = 3" diff --git a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt index 5a3a4617969..d8bd387cb66 100644 --- a/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt +++ b/spring-test/src/main/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensions.kt @@ -17,7 +17,6 @@ package org.springframework.test.web.reactive.server import org.reactivestreams.Publisher -import kotlin.reflect.KClass /** * Extension for [WebTestClient.RequestBodySpec.body] providing a variant without explicit class @@ -29,15 +28,6 @@ import kotlin.reflect.KClass inline fun > WebTestClient.RequestBodySpec.body(publisher: S): WebTestClient.RequestHeadersSpec<*> = body(publisher, T::class.java) -/** - * Extension for [WebTestClient.ResponseSpec.expectBody] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun WebTestClient.ResponseSpec.expectBody(type: KClass): WebTestClient.BodySpec = - expectBody(type.java) - /** * Extension for [WebTestClient.ResponseSpec.expectBody] providing a `expectBody()` variant. * @@ -47,15 +37,6 @@ fun WebTestClient.ResponseSpec.expectBody(type: KClass): WebTestCli inline fun WebTestClient.ResponseSpec.expectBody(): WebTestClient.BodySpec = expectBody(B::class.java) -/** - * Extension for [WebTestClient.ResponseSpec.expectBodyList] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun WebTestClient.ResponseSpec.expectBodyList(type: KClass): WebTestClient.ListBodySpec = - expectBodyList(type.java) - /** * Extension for [WebTestClient.ResponseSpec.expectBodyList] providing a `expectBodyList()` variant. * @@ -65,15 +46,6 @@ fun WebTestClient.ResponseSpec.expectBodyList(type: KClass): WebTes inline fun WebTestClient.ResponseSpec.expectBodyList(): WebTestClient.ListBodySpec = expectBodyList(E::class.java) -/** - * Extension for [WebTestClient.ResponseSpec.returnResult] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun WebTestClient.ResponseSpec.returnResult(type: KClass): FluxExchangeResult = - returnResult(type.java) - /** * Extension for [WebTestClient.ResponseSpec.returnResult] providing a `returnResult()` variant. * diff --git a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt index 5feb8202362..20f5f872013 100644 --- a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt +++ b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt @@ -33,36 +33,18 @@ class WebTestClientExtensionsTests { verify(requestBodySpec, times(1)).body(body, Foo::class.java) } - @Test - fun `ResponseSpec#expectBody with KClass`() { - responseSpec.expectBody(Foo::class) - verify(responseSpec, times(1)).expectBody(Foo::class.java) - } - @Test fun `ResponseSpec#expectBody with reified type parameters`() { responseSpec.expectBody() verify(responseSpec, times(1)).expectBody(Foo::class.java) } - @Test - fun `ResponseSpec#expectBodyList with KClass`() { - responseSpec.expectBodyList(Foo::class) - verify(responseSpec, times(1)).expectBodyList(Foo::class.java) - } - @Test fun `ResponseSpec#expectBodyList with reified type parameters`() { responseSpec.expectBodyList() verify(responseSpec, times(1)).expectBodyList(Foo::class.java) } - @Test - fun `ResponseSpec#returnResult with KClass`() { - responseSpec.returnResult(Foo::class) - verify(responseSpec, times(1)).returnResult(Foo::class.java) - } - @Test fun `ResponseSpec#returnResult with reified type parameters`() { responseSpec.returnResult() diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/BodyExtractorsExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/BodyExtractorsExtensions.kt index b084b168257..5ad43ef129c 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/BodyExtractorsExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/BodyExtractorsExtensions.kt @@ -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 bodyToMono(): BodyExtractor, 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 bodyToMono(elementClass: KClass): BodyExtractor, ReactiveHttpInputMessage> = - BodyExtractors.toMono(elementClass.java) - /** * Function for providing a `bodyToFlux()` alternative to `BodyExtractors.toFlux(Foo::class.java)`. * @@ -35,12 +24,3 @@ fun bodyToMono(elementClass: KClass): BodyExtractor, Reacti inline fun bodyToFlux(): BodyExtractor, 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 bodyToFlux(elementClass: KClass): BodyExtractor, ReactiveHttpInputMessage> = - BodyExtractors.toFlux(elementClass.java) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt index 91fdeb7db9e..d133df0bc56 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensions.kt @@ -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 ClientResponse.bodyToMono(type: KClass): Mono = bodyToMono(type.java) - /** * Extension for [ClientResponse.bodyToMono] providing a `bodyToMono()` variant. * @@ -21,15 +12,6 @@ fun ClientResponse.bodyToMono(type: KClass): Mono = bodyToMono(t */ inline fun ClientResponse.bodyToMono(): Mono = bodyToMono(T::class.java) - -/** - * Extension for [ClientResponse.bodyToFlux] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun ClientResponse.bodyToFlux(type: KClass): Flux = bodyToFlux(type.java) - /** * Extension for [ClientResponse.bodyToFlux] providing a `bodyToFlux()` variant. * diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt index 5f8d2d59a3c..462a9b9d71d 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt @@ -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 > 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 WebClient.ResponseSpec.bodyToMono(type: KClass): Mono = bodyToMono(type.java) - /** * Extension for [WebClient.ResponseSpec.bodyToMono] providing a `bodyToMono()` variant. * @@ -50,14 +42,6 @@ fun WebClient.ResponseSpec.bodyToMono(type: KClass): Mono = body inline fun WebClient.ResponseSpec.bodyToMono(): Mono = bodyToMono(T::class.java) -/** - * Extension for [WebClient.ResponseSpec.bodyToFlux] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun WebClient.ResponseSpec.bodyToFlux(type: KClass): Flux = bodyToFlux(type.java) - /** * Extension for [WebClient.ResponseSpec.bodyToFlux] providing a `bodyToFlux()` variant. * @@ -66,14 +50,6 @@ fun WebClient.ResponseSpec.bodyToFlux(type: KClass): Flux = body */ inline fun WebClient.ResponseSpec.bodyToFlux(): Flux = bodyToFlux(T::class.java) -/** - * Extension for [WebClient.ResponseSpec.toEntity] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun WebClient.ResponseSpec.toEntity(type: KClass): Mono> = toEntity(type.java) - /** * Extension for [WebClient.ResponseSpec.toEntity] providing a `bodyToEntity()` variant. * @@ -82,14 +58,6 @@ fun WebClient.ResponseSpec.toEntity(type: KClass): Mono WebClient.ResponseSpec.toEntity(): Mono> = toEntity(T::class.java) -/** - * Extension for [WebClient.ResponseSpec.toEntityList] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun WebClient.ResponseSpec.toEntityList(type: KClass): Mono>> = toEntityList(type.java) - /** * Extension for [WebClient.ResponseSpec.toEntityList] providing a `bodyToEntityList()` variant. * diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt index 33ad080a4f6..1e5bb438c34 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensions.kt @@ -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 ServerRequest.bodyToMono(type: KClass): Mono = bodyToMono(type.java) - /** * Extension for [ServerRequest.bodyToMono] providing a `bodyToMono()` variant. * @@ -21,14 +12,6 @@ fun ServerRequest.bodyToMono(type: KClass): Mono = bodyToMono(ty */ inline fun ServerRequest.bodyToMono(): Mono = bodyToMono(T::class.java) -/** - * Extension for [ServerRequest.bodyToFlux] providing a [KClass] based variant. - * - * @author Sebastien Deleuze - * @since 5.0 - */ -fun ServerRequest.bodyToFlux(type: KClass): Flux = bodyToFlux(type.java) - /** * Extension for [ServerRequest.bodyToFlux] providing a `bodyToFlux()` variant. * diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/BodyExtractorsExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/BodyExtractorsExtensionsTests.kt index 40d7849b56b..929135f24e7 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/BodyExtractorsExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/BodyExtractorsExtensionsTests.kt @@ -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()) } - @Test - fun `bodyToFlux with KClass`() { - assertNotNull(bodyToFlux(Foo::class)) - } - @Test fun `bodyToFlux with reified type parameter`() { assertNotNull(bodyToFlux()) diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt index 8fe85133bd0..7560448de4e 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt @@ -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() 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() diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt index 038b42ab54a..dcf5098983f 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt @@ -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() 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() 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() 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() diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt index 7c87d93c495..80775439902 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt @@ -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() 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()