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 dc4f4d188b..ed5f855749 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 @@ -9,7 +9,7 @@ import kotlin.reflect.KClass * @author Sebastien Deleuze * @since 5.0 */ -fun BeanFactory.getBean(requiredType: KClass) = getBean(requiredType.java) +fun BeanFactory.getBean(requiredType: KClass): T = getBean(requiredType.java) /** * Extension for [BeanFactory.getBean] providing a `getBean()` variant. @@ -17,7 +17,7 @@ fun BeanFactory.getBean(requiredType: KClass) = getBean(requiredTyp * @author Sebastien Deleuze * @since 5.0 */ -inline fun BeanFactory.getBean() = getBean(T::class.java) +inline fun BeanFactory.getBean(): T = getBean(T::class.java) /** * Extension for [BeanFactory.getBean] providing a [KClass] based variant. @@ -26,7 +26,7 @@ inline fun BeanFactory.getBean() = getBean(T::class.java) * @author Sebastien Deleuze * @since 5.0 */ -fun BeanFactory.getBean(name: String, requiredType: KClass) = +fun BeanFactory.getBean(name: String, requiredType: KClass): T = getBean(name, requiredType.java) /** @@ -37,7 +37,7 @@ fun BeanFactory.getBean(name: String, requiredType: KClass) = * @since 5.0 */ @Suppress("EXTENSION_SHADOWED_BY_MEMBER") -inline fun BeanFactory.getBean(name: String) = +inline fun BeanFactory.getBean(name: String): T = getBean(name, T::class.java) /** @@ -47,7 +47,7 @@ inline fun BeanFactory.getBean(name: String) = * @author Sebastien Deleuze * @since 5.0 */ -fun BeanFactory.getBean(requiredType: KClass, vararg args:Any) = +fun BeanFactory.getBean(requiredType: KClass, vararg args:Any): T = getBean(requiredType.java, *args) /** @@ -57,5 +57,5 @@ fun BeanFactory.getBean(requiredType: KClass, vararg args:Any) = * @author Sebastien Deleuze * @since 5.0 */ -inline fun BeanFactory.getBean(vararg args:Any) = +inline fun BeanFactory.getBean(vararg args:Any): T = getBean(T::class.java, *args) 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 4f369865e0..cf7f418a43 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 @@ -10,8 +10,8 @@ import kotlin.reflect.KClass * @since 5.0 */ fun ListableBeanFactory.getBeanNamesForType(type: KClass, - includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) = - getBeanNamesForType(type.java, includeNonSingletons, allowEagerInit) + includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Array = + getBeanNamesForType(type.java, includeNonSingletons, allowEagerInit) /** * Extension for [ListableBeanFactory.getBeanNamesForType] providing a `getBeanNamesForType()` variant. @@ -19,8 +19,8 @@ fun ListableBeanFactory.getBeanNamesForType(type: KClass, * @author Sebastien Deleuze * @since 5.0 */ -inline fun ListableBeanFactory.getBeanNamesForType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) = - getBeanNamesForType(T::class.java, includeNonSingletons, allowEagerInit) +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. @@ -28,9 +28,8 @@ inline fun ListableBeanFactory.getBeanNamesForType(includeNonS * @author Sebastien Deleuze * @since 5.0 */ -fun ListableBeanFactory.getBeansOfType(type: KClass, - includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) = - getBeansOfType(type.java, includeNonSingletons, allowEagerInit) +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. @@ -38,7 +37,7 @@ fun ListableBeanFactory.getBeansOfType(type: KClass, * @author Sebastien Deleuze * @since 5.0 */ -inline fun ListableBeanFactory.getBeansOfType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) = +inline fun ListableBeanFactory.getBeansOfType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Map = getBeansOfType(T::class.java, includeNonSingletons, allowEagerInit) /** @@ -47,7 +46,7 @@ inline fun ListableBeanFactory.getBeansOfType(includeNonSingle * @author Sebastien Deleuze * @since 5.0 */ -fun ListableBeanFactory.getBeanNamesForAnnotation(type: KClass) = +fun ListableBeanFactory.getBeanNamesForAnnotation(type: KClass): Array = getBeanNamesForAnnotation(type.java) /** @@ -56,7 +55,7 @@ fun ListableBeanFactory.getBeanNamesForAnnotation(type: KClass< * @author Sebastien Deleuze * @since 5.0 */ -inline fun ListableBeanFactory.getBeanNamesForAnnotation() = +inline fun ListableBeanFactory.getBeanNamesForAnnotation(): Array = getBeanNamesForAnnotation(T::class.java) /** @@ -65,7 +64,7 @@ inline fun ListableBeanFactory.getBeanNamesForAnnotatio * @author Sebastien Deleuze * @since 5.0 */ -fun ListableBeanFactory.getBeansWithAnnotation(type: KClass) = +fun ListableBeanFactory.getBeansWithAnnotation(type: KClass): MutableMap = getBeansWithAnnotation(type.java) /** @@ -74,7 +73,7 @@ fun ListableBeanFactory.getBeansWithAnnotation(type: KClass) * @author Sebastien Deleuze * @since 5.0 */ -inline fun ListableBeanFactory.getBeansWithAnnotation() = +inline fun ListableBeanFactory.getBeansWithAnnotation(): MutableMap = getBeansWithAnnotation(T::class.java) /** @@ -83,7 +82,7 @@ inline fun ListableBeanFactory.getBeansWithAnnotation() * @author Sebastien Deleuze * @since 5.0 */ -fun ListableBeanFactory.findAnnotationOnBean(beanName:String, type: KClass) = +fun ListableBeanFactory.findAnnotationOnBean(beanName:String, type: KClass): Annotation? = findAnnotationOnBean(beanName, type.java) /** @@ -92,6 +91,6 @@ fun ListableBeanFactory.findAnnotationOnBean(beanName:String, t * @author Sebastien Deleuze * @since 5.0 */ -inline fun ListableBeanFactory.findAnnotationOnBean(beanName:String) = +inline fun ListableBeanFactory.findAnnotationOnBean(beanName:String): Annotation? = findAnnotationOnBean(beanName, T::class.java) diff --git a/spring-context/src/main/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensions.kt b/spring-context/src/main/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensions.kt index 802598309c..0a16ac2007 100644 --- a/spring-context/src/main/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensions.kt +++ b/spring-context/src/main/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensions.kt @@ -7,5 +7,5 @@ package org.springframework.context.annotation * @author Sebastien Deleuze * @since 5.0 */ -fun AnnotationConfigApplicationContext(configure: AnnotationConfigApplicationContext.()->Unit) = +fun AnnotationConfigApplicationContext(configure: AnnotationConfigApplicationContext.() -> Unit) = AnnotationConfigApplicationContext().apply(configure) 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 7337dddb69..59acb1fae6 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 @@ -12,9 +12,8 @@ import kotlin.reflect.KClass * @author Sebastien Deleuze * @since 5.0 */ -fun GenericApplicationContext.registerBean(beanClass: KClass, - vararg customizers: BeanDefinitionCustomizer) { - registerBean(beanClass.java, *customizers) +fun GenericApplicationContext.registerBean(beanClass: KClass, vararg customizers: BeanDefinitionCustomizer) { + registerBean(beanClass.java, *customizers) } /** @@ -24,7 +23,7 @@ fun GenericApplicationContext.registerBean(beanClass: KClass, * @since 5.0 */ inline fun GenericApplicationContext.registerBean(vararg customizers: BeanDefinitionCustomizer) { - registerBean(T::class.java, *customizers) + registerBean(T::class.java, *customizers) } /** @@ -33,9 +32,8 @@ inline fun GenericApplicationContext.registerBean(vararg custo * @author Sebastien Deleuze * @since 5.0 */ -fun GenericApplicationContext.registerBean(beanName: String, beanClass: KClass, - vararg customizers: BeanDefinitionCustomizer) { - registerBean(beanName, beanClass.java, *customizers) +fun GenericApplicationContext.registerBean(beanName: String, beanClass: KClass, vararg customizers: BeanDefinitionCustomizer) { + registerBean(beanName, beanClass.java, *customizers) } /** @@ -45,7 +43,7 @@ fun GenericApplicationContext.registerBean(beanName: String, beanClass * @since 5.0 */ inline fun GenericApplicationContext.registerBean(beanName: String, vararg customizers: BeanDefinitionCustomizer) { - registerBean(beanName, T::class.java, *customizers) + registerBean(beanName, T::class.java, *customizers) } /** @@ -56,7 +54,7 @@ inline fun GenericApplicationContext.registerBean(beanName: St */ inline fun GenericApplicationContext.registerBean( vararg customizers: BeanDefinitionCustomizer, crossinline function: (ApplicationContext) -> T) { - registerBean(T::class.java, Supplier { function.invoke(this) }, *customizers) + registerBean(T::class.java, Supplier { function.invoke(this) }, *customizers) } /** @@ -67,7 +65,7 @@ inline fun GenericApplicationContext.registerBean( */ inline fun GenericApplicationContext.registerBean(name: String, vararg customizers: BeanDefinitionCustomizer, crossinline function: (ApplicationContext) -> T) { - registerBean(name, T::class.java, Supplier { function.invoke(this) }, *customizers) + registerBean(name, T::class.java, Supplier { function.invoke(this) }, *customizers) } /** @@ -76,5 +74,5 @@ inline fun GenericApplicationContext.registerBean(name: String * @author Sebastien Deleuze * @since 5.0 */ -fun GenericApplicationContext(configure: GenericApplicationContext.()->Unit) = GenericApplicationContext().apply(configure) +fun GenericApplicationContext(configure: GenericApplicationContext.() -> Unit) = GenericApplicationContext().apply(configure) diff --git a/spring-web/src/main/kotlin/org/springframework/web/client/RestOperationsExtensions.kt b/spring-web/src/main/kotlin/org/springframework/web/client/RestOperationsExtensions.kt index c74be74ec6..e6a2dc30b2 100644 --- a/spring-web/src/main/kotlin/org/springframework/web/client/RestOperationsExtensions.kt +++ b/spring-web/src/main/kotlin/org/springframework/web/client/RestOperationsExtensions.kt @@ -3,6 +3,7 @@ package org.springframework.web.client import org.springframework.http.HttpEntity import org.springframework.http.HttpMethod import org.springframework.http.RequestEntity +import org.springframework.http.ResponseEntity import java.net.URI @@ -14,7 +15,7 @@ import java.net.URI * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.getForObject(url: String, vararg uriVariables: Any) = +inline fun RestOperations.getForObject(url: String, vararg uriVariables: Any): T = getForObject(url, T::class.java, *uriVariables) /** @@ -25,7 +26,7 @@ inline fun RestOperations.getForObject(url: String, vararg uriV * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.getForObject(url: String, uriVariables: Map) = +inline fun RestOperations.getForObject(url: String, uriVariables: Map): T = getForObject(url, T::class.java, uriVariables) /** @@ -36,7 +37,7 @@ inline fun RestOperations.getForObject(url: String, uriVariable * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.getForObject(url: URI) = +inline fun RestOperations.getForObject(url: URI): T = getForObject(url, T::class.java) /** @@ -47,7 +48,7 @@ inline fun RestOperations.getForObject(url: URI) = * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.getForEntity(url: String, vararg uriVariables: Any) = +inline fun RestOperations.getForEntity(url: String, vararg uriVariables: Any): ResponseEntity = getForEntity(url, T::class.java, *uriVariables) /** @@ -58,7 +59,7 @@ inline fun RestOperations.getForEntity(url: String, vararg uriV * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.postForObject(url: String, request: Any, vararg uriVariables: Any) = +inline fun RestOperations.postForObject(url: String, request: Any, vararg uriVariables: Any): T = postForObject(url, request, T::class.java, *uriVariables) /** @@ -69,7 +70,7 @@ inline fun RestOperations.postForObject(url: String, request: A * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.postForObject(url: String, request: Any, uriVariables: Map) = +inline fun RestOperations.postForObject(url: String, request: Any, uriVariables: Map): T = postForObject(url, request, T::class.java, uriVariables) /** @@ -78,7 +79,7 @@ inline fun RestOperations.postForObject(url: String, request: A * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.postForObject(url: URI, request: Any) = +inline fun RestOperations.postForObject(url: URI, request: Any): T = postForObject(url, request, T::class.java) /** @@ -89,7 +90,7 @@ inline fun RestOperations.postForObject(url: URI, request: Any) * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.postForEntity(url: String, request: Any, vararg uriVariables: Any) = +inline fun RestOperations.postForEntity(url: String, request: Any, vararg uriVariables: Any): ResponseEntity = postForEntity(url, request, T::class.java, *uriVariables) /** @@ -100,7 +101,7 @@ inline fun RestOperations.postForEntity(url: String, request: A * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.postForEntity(url: String, request: Any, uriVariables: Map) = +inline fun RestOperations.postForEntity(url: String, request: Any, uriVariables: Map): ResponseEntity = postForEntity(url, request, T::class.java, uriVariables) /** @@ -111,7 +112,7 @@ inline fun RestOperations.postForEntity(url: String, request: A * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.postForEntity(url: URI, request: Any) = +inline fun RestOperations.postForEntity(url: URI, request: Any): ResponseEntity = postForEntity(url, request, T::class.java) /** @@ -122,7 +123,7 @@ inline fun RestOperations.postForEntity(url: URI, request: Any) * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, vararg uriVariables: Any) = +inline fun RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, vararg uriVariables: Any): ResponseEntity = exchange(url, method, requestEntity, T::class.java, *uriVariables) /** @@ -133,7 +134,7 @@ inline fun RestOperations.exchange(url: String, method: HttpMet * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, uriVariables: Map) = +inline fun RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, uriVariables: Map): ResponseEntity = exchange(url, method, requestEntity, T::class.java, uriVariables) /** @@ -144,7 +145,7 @@ inline fun RestOperations.exchange(url: String, method: HttpMet * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.exchange(url: URI, method: HttpMethod, requestEntity: HttpEntity<*>) = +inline fun RestOperations.exchange(url: URI, method: HttpMethod, requestEntity: HttpEntity<*>): ResponseEntity = exchange(url, method, requestEntity, T::class.java) /** @@ -155,5 +156,5 @@ inline fun RestOperations.exchange(url: URI, method: HttpMethod * @since 5.0 */ @Throws(RestClientException::class) -inline fun RestOperations.exchange(requestEntity: RequestEntity<*>) = +inline fun RestOperations.exchange(requestEntity: RequestEntity<*>): ResponseEntity = exchange(requestEntity, T::class.java) 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 cc92004282..8dc50e51e1 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 @@ -11,7 +11,7 @@ import kotlin.reflect.KClass * @author Sebastien Deleuze * @since 5.0 */ -inline fun toMono() : BodyExtractor, ReactiveHttpInputMessage> = +inline fun toMono(): BodyExtractor, ReactiveHttpInputMessage> = BodyExtractors.toMono(T::class.java) /** @@ -20,7 +20,7 @@ inline fun toMono() : BodyExtractor, ReactiveHttpInput * @author Sebastien Deleuze * @since 5.0 */ -fun toMono(elementClass: KClass) : BodyExtractor, ReactiveHttpInputMessage> = +fun toMono(elementClass: KClass): BodyExtractor, ReactiveHttpInputMessage> = BodyExtractors.toMono(elementClass.java) /** @@ -29,7 +29,7 @@ fun toMono(elementClass: KClass) : BodyExtractor, ReactiveH * @author Sebastien Deleuze * @since 5.0 */ -inline fun toFlux() : BodyExtractor, ReactiveHttpInputMessage> = +inline fun toFlux(): BodyExtractor, ReactiveHttpInputMessage> = BodyExtractors.toFlux(T::class.java) /** @@ -38,5 +38,5 @@ inline fun toFlux() : BodyExtractor, ReactiveHttpInput * @author Sebastien Deleuze * @since 5.0 */ -fun toFlux(elementClass: KClass) : BodyExtractor, ReactiveHttpInputMessage> = +fun toFlux(elementClass: KClass): BodyExtractor, ReactiveHttpInputMessage> = BodyExtractors.toFlux(elementClass.java) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/BodyInsertersExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/BodyInsertersExtensions.kt index ac50aba2f4..849d093896 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/BodyInsertersExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/BodyInsertersExtensions.kt @@ -10,7 +10,7 @@ import org.springframework.http.server.reactive.ServerHttpResponse * @author Sebastien Deleuze * @since 5.0 */ -inline fun , reified S : Any> fromPublisher(publisher: T) : BodyInserter = +inline fun , reified S : Any> fromPublisher(publisher: T): BodyInserter = BodyInserters.fromPublisher(publisher, S::class.java) /** @@ -19,5 +19,5 @@ inline fun , reified S : Any> fromPublisher(publisher: * @author Sebastien Deleuze * @since 5.0 */ -inline fun , reified S : Any> fromServerSentEvents(publisher: T) : BodyInserter = +inline fun , reified S : Any> fromServerSentEvents(publisher: T): BodyInserter = BodyInserters.fromServerSentEvents(publisher, S::class.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 ae539d54de..91fdeb7db9 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 @@ -11,7 +11,7 @@ import kotlin.reflect.KClass * @author Sebastien Deleuze * @since 5.0 */ -fun ClientResponse.bodyToMono(type: KClass) : Mono = bodyToMono(type.java) +fun ClientResponse.bodyToMono(type: KClass): Mono = bodyToMono(type.java) /** * Extension for [ClientResponse.bodyToMono] providing a `bodyToMono()` variant. @@ -19,7 +19,7 @@ fun ClientResponse.bodyToMono(type: KClass) : Mono = bodyToMono( * @author Sebastien Deleuze * @since 5.0 */ -inline fun ClientResponse.bodyToMono() = bodyToMono(T::class.java) +inline fun ClientResponse.bodyToMono(): Mono = bodyToMono(T::class.java) /** @@ -28,7 +28,7 @@ inline fun ClientResponse.bodyToMono() = bodyToMono(T::class.j * @author Sebastien Deleuze * @since 5.0 */ -fun ClientResponse.bodyToFlux(type: KClass) : Flux = bodyToFlux(type.java) +fun ClientResponse.bodyToFlux(type: KClass): Flux = bodyToFlux(type.java) /** * Extension for [ClientResponse.bodyToFlux] providing a `bodyToFlux()` variant. @@ -36,4 +36,4 @@ fun ClientResponse.bodyToFlux(type: KClass) : Flux = bodyToFlux( * @author Sebastien Deleuze * @since 5.0 */ -inline fun ClientResponse.bodyToFlux() = bodyToFlux(T::class.java) +inline fun ClientResponse.bodyToFlux(): Flux = bodyToFlux(T::class.java) 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 1b41cfaf0b..7c0c0a8571 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 @@ -17,6 +17,7 @@ package org.springframework.web.reactive.function.client import org.reactivestreams.Publisher +import reactor.core.publisher.Mono /** * Extension for [WebClient.RequestHeadersSpec.exchangePublisher] providing a variant without explicit class @@ -25,5 +26,5 @@ import org.reactivestreams.Publisher * @author Sebastien Deleuze * @since 5.0 */ -inline fun > WebClient.RequestBodySpec.body(publisher: S) = - body(publisher, T::class.java) +inline fun > WebClient.RequestBodySpec.body(publisher: S): + Mono = body(publisher, T::class.java) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt index 6e48eb4aec..5cca535de7 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/RouterFunctionExtensions.kt @@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.server import org.springframework.core.io.Resource import org.springframework.http.HttpMethod import org.springframework.http.MediaType -import org.springframework.web.reactive.function.server.RequestPredicates.pathPrefix +import org.springframework.web.reactive.function.server.RequestPredicates.* import reactor.core.publisher.Mono /** @@ -96,92 +96,92 @@ class RouterDsl { routes += RouterFunctions.route(RequestPredicates.GET(pattern), HandlerFunction { f(it) }) } - fun GET(pattern: String) = RequestPredicates.GET(pattern) + fun GET(pattern: String): RequestPredicate = RequestPredicates.GET(pattern) fun HEAD(pattern: String, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.HEAD(pattern), HandlerFunction { f(it) }) } - fun HEAD(pattern: String) = RequestPredicates.HEAD(pattern) + fun HEAD(pattern: String): RequestPredicate = RequestPredicates.HEAD(pattern) fun POST(pattern: String, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.POST(pattern), HandlerFunction { f(it) }) } - fun POST(pattern: String) = RequestPredicates.POST(pattern) + fun POST(pattern: String): RequestPredicate = RequestPredicates.POST(pattern) fun PUT(pattern: String, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.PUT(pattern), HandlerFunction { f(it) }) } - fun PUT(pattern: String) = RequestPredicates.PUT(pattern) + fun PUT(pattern: String): RequestPredicate = RequestPredicates.PUT(pattern) fun PATCH(pattern: String, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.PATCH(pattern), HandlerFunction { f(it) }) } - fun PATCH(pattern: String) = RequestPredicates.PATCH(pattern) + fun PATCH(pattern: String): RequestPredicate = RequestPredicates.PATCH(pattern) fun DELETE(pattern: String, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.DELETE(pattern), HandlerFunction { f(it) }) } - fun DELETE(pattern: String) = RequestPredicates.DELETE(pattern) + fun DELETE(pattern: String): RequestPredicate = RequestPredicates.DELETE(pattern) fun OPTIONS(pattern: String, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.OPTIONS(pattern), HandlerFunction { f(it) }) } - fun OPTIONS(pattern: String) = RequestPredicates.OPTIONS(pattern) + fun OPTIONS(pattern: String): RequestPredicate = RequestPredicates.OPTIONS(pattern) fun accept(mediaType: MediaType, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.accept(mediaType), HandlerFunction { f(it) }) } - fun accept(mediaType: MediaType) = RequestPredicates.accept(mediaType) + fun accept(mediaType: MediaType): RequestPredicate = RequestPredicates.accept(mediaType) fun contentType(mediaType: MediaType, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.contentType(mediaType), HandlerFunction { f(it) }) } - fun contentType(mediaType: MediaType) = RequestPredicates.contentType(mediaType) + fun contentType(mediaType: MediaType): RequestPredicate = RequestPredicates.contentType(mediaType) fun headers(headerPredicate: (ServerRequest.Headers) -> Boolean, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.headers(headerPredicate), HandlerFunction { f(it) }) } - fun headers(headerPredicate: (ServerRequest.Headers) -> Boolean) = RequestPredicates.headers(headerPredicate) + fun headers(headerPredicate: (ServerRequest.Headers) -> Boolean): RequestPredicate = RequestPredicates.headers(headerPredicate) fun method(httpMethod: HttpMethod, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.method(httpMethod), HandlerFunction { f(it) }) } - fun method(httpMethod: HttpMethod) = RequestPredicates.method(httpMethod) + fun method(httpMethod: HttpMethod): RequestPredicate = RequestPredicates.method(httpMethod) fun path(pattern: String, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.path(pattern), HandlerFunction { f(it) }) } - fun path(pattern: String) = RequestPredicates.path(pattern) + fun path(pattern: String): RequestPredicate = RequestPredicates.path(pattern) fun pathExtension(extension: String, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.pathExtension(extension), HandlerFunction { f(it) }) } - fun pathExtension(extension: String) = RequestPredicates.pathExtension(extension) + fun pathExtension(extension: String): RequestPredicate = RequestPredicates.pathExtension(extension) fun pathExtension(predicate: (String) -> Boolean, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.pathExtension(predicate), HandlerFunction { f(it) }) } - fun pathExtension(predicate: (String) -> Boolean) = RequestPredicates.pathExtension(predicate) + fun pathExtension(predicate: (String) -> Boolean): RequestPredicate = RequestPredicates.pathExtension(predicate) fun queryParam(name: String, predicate: (String) -> Boolean, f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.queryParam(name, predicate), HandlerFunction { f(it) }) } - fun queryParam(name: String, predicate: (String) -> Boolean) = RequestPredicates.queryParam(name, predicate) + fun queryParam(name: String, predicate: (String) -> Boolean): RequestPredicate = RequestPredicates.queryParam(name, predicate) operator fun String.invoke(f: (ServerRequest) -> Mono) { routes += RouterFunctions.route(RequestPredicates.path(this), HandlerFunction { f(it) }) 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 dc76c67395..33ad080a4f 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 @@ -1,5 +1,7 @@ package org.springframework.web.reactive.function.server +import reactor.core.publisher.Flux +import reactor.core.publisher.Mono import kotlin.reflect.KClass @@ -9,7 +11,7 @@ import kotlin.reflect.KClass * @author Sebastien Deleuze * @since 5.0 */ -fun ServerRequest.bodyToMono(type: KClass) = bodyToMono(type.java) +fun ServerRequest.bodyToMono(type: KClass): Mono = bodyToMono(type.java) /** * Extension for [ServerRequest.bodyToMono] providing a `bodyToMono()` variant. @@ -17,7 +19,7 @@ fun ServerRequest.bodyToMono(type: KClass) = bodyToMono(type.java) * @author Sebastien Deleuze * @since 5.0 */ -inline fun ServerRequest.bodyToMono() = bodyToMono(T::class.java) +inline fun ServerRequest.bodyToMono(): Mono = bodyToMono(T::class.java) /** * Extension for [ServerRequest.bodyToFlux] providing a [KClass] based variant. @@ -25,7 +27,7 @@ inline fun ServerRequest.bodyToMono() = bodyToMono(T::class.ja * @author Sebastien Deleuze * @since 5.0 */ -fun ServerRequest.bodyToFlux(type: KClass) = bodyToFlux(type.java) +fun ServerRequest.bodyToFlux(type: KClass): Flux = bodyToFlux(type.java) /** * Extension for [ServerRequest.bodyToFlux] providing a `bodyToFlux()` variant. @@ -33,4 +35,4 @@ fun ServerRequest.bodyToFlux(type: KClass) = bodyToFlux(type.java) * @author Sebastien Deleuze * @since 5.0 */ -inline fun ServerRequest.bodyToFlux() = bodyToFlux(T::class.java) +inline fun ServerRequest.bodyToFlux(): Flux = bodyToFlux(T::class.java) diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt index a11422c372..362d863527 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt @@ -1,6 +1,7 @@ package org.springframework.web.reactive.function.server import org.reactivestreams.Publisher +import reactor.core.publisher.Mono /** * Extension for [ServerResponse.BodyBuilder.body] providing a `body(Publisher)` variant. @@ -8,4 +9,4 @@ import org.reactivestreams.Publisher * @author Sebastien Deleuze * @since 5.0 */ -inline fun ServerResponse.BodyBuilder.body(publisher: Publisher) = body(publisher, T::class.java) \ No newline at end of file +inline fun ServerResponse.BodyBuilder.body(publisher: Publisher): Mono = body(publisher, T::class.java) \ No newline at end of file