Specify explicitly Kotlin extensions return type
The main purpose is to specify nullability.
This commit is contained in:
parent
cd8c365a0d
commit
e2fd398bad
|
@ -9,7 +9,7 @@ import kotlin.reflect.KClass
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>) = getBean(requiredType.java)
|
||||
fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>): T = getBean(requiredType.java)
|
||||
|
||||
/**
|
||||
* Extension for [BeanFactory.getBean] providing a `getBean<Foo>()` variant.
|
||||
|
@ -17,7 +17,7 @@ fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>) = getBean(requiredTyp
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> BeanFactory.getBean() = getBean(T::class.java)
|
||||
inline fun <reified T : Any> BeanFactory.getBean(): T = getBean(T::class.java)
|
||||
|
||||
/**
|
||||
* Extension for [BeanFactory.getBean] providing a [KClass] based variant.
|
||||
|
@ -26,7 +26,7 @@ inline fun <reified T : Any> BeanFactory.getBean() = getBean(T::class.java)
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> BeanFactory.getBean(name: String, requiredType: KClass<T>) =
|
||||
fun <T : Any> BeanFactory.getBean(name: String, requiredType: KClass<T>): T =
|
||||
getBean(name, requiredType.java)
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ fun <T : Any> BeanFactory.getBean(name: String, requiredType: KClass<T>) =
|
|||
* @since 5.0
|
||||
*/
|
||||
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
|
||||
inline fun <reified T : Any> BeanFactory.getBean(name: String) =
|
||||
inline fun <reified T : Any> BeanFactory.getBean(name: String): T =
|
||||
getBean(name, T::class.java)
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ inline fun <reified T : Any> BeanFactory.getBean(name: String) =
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>, vararg args:Any) =
|
||||
fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>, vararg args:Any): T =
|
||||
getBean(requiredType.java, *args)
|
||||
|
||||
/**
|
||||
|
@ -57,5 +57,5 @@ fun <T : Any> BeanFactory.getBean(requiredType: KClass<T>, vararg args:Any) =
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> BeanFactory.getBean(vararg args:Any) =
|
||||
inline fun <reified T : Any> BeanFactory.getBean(vararg args:Any): T =
|
||||
getBean(T::class.java, *args)
|
||||
|
|
|
@ -10,8 +10,8 @@ import kotlin.reflect.KClass
|
|||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> ListableBeanFactory.getBeanNamesForType(type: KClass<T>,
|
||||
includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
||||
getBeanNamesForType(type.java, includeNonSingletons, allowEagerInit)
|
||||
includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Array<out String> =
|
||||
getBeanNamesForType(type.java, includeNonSingletons, allowEagerInit)
|
||||
|
||||
/**
|
||||
* Extension for [ListableBeanFactory.getBeanNamesForType] providing a `getBeanNamesForType<Foo>()` variant.
|
||||
|
@ -19,8 +19,8 @@ fun <T : Any> ListableBeanFactory.getBeanNamesForType(type: KClass<T>,
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> ListableBeanFactory.getBeanNamesForType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
||||
getBeanNamesForType(T::class.java, includeNonSingletons, allowEagerInit)
|
||||
inline fun <reified T : Any> ListableBeanFactory.getBeanNamesForType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Array<out String> =
|
||||
getBeanNamesForType(T::class.java, includeNonSingletons, allowEagerInit)
|
||||
|
||||
/**
|
||||
* Extension for [ListableBeanFactory.getBeansOfType] providing a [KClass] based variant.
|
||||
|
@ -28,9 +28,8 @@ inline fun <reified T : Any> ListableBeanFactory.getBeanNamesForType(includeNonS
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> ListableBeanFactory.getBeansOfType(type: KClass<T>,
|
||||
includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
||||
getBeansOfType(type.java, includeNonSingletons, allowEagerInit)
|
||||
fun <T : Any> ListableBeanFactory.getBeansOfType(type: KClass<T>, includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Map<String, Any> =
|
||||
getBeansOfType(type.java, includeNonSingletons, allowEagerInit)
|
||||
|
||||
/**
|
||||
* Extension for [ListableBeanFactory.getBeansOfType] providing a `getBeansOfType<Foo>()` variant.
|
||||
|
@ -38,7 +37,7 @@ fun <T : Any> ListableBeanFactory.getBeansOfType(type: KClass<T>,
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> ListableBeanFactory.getBeansOfType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true) =
|
||||
inline fun <reified T : Any> ListableBeanFactory.getBeansOfType(includeNonSingletons: Boolean = true, allowEagerInit: Boolean = true): Map<String, Any> =
|
||||
getBeansOfType(T::class.java, includeNonSingletons, allowEagerInit)
|
||||
|
||||
/**
|
||||
|
@ -47,7 +46,7 @@ inline fun <reified T : Any> ListableBeanFactory.getBeansOfType(includeNonSingle
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation(type: KClass<T>) =
|
||||
fun <T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation(type: KClass<T>): Array<out String> =
|
||||
getBeanNamesForAnnotation(type.java)
|
||||
|
||||
/**
|
||||
|
@ -56,7 +55,7 @@ fun <T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation(type: KClass<
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation() =
|
||||
inline fun <reified T : Annotation> ListableBeanFactory.getBeanNamesForAnnotation(): Array<out String> =
|
||||
getBeanNamesForAnnotation(T::class.java)
|
||||
|
||||
/**
|
||||
|
@ -65,7 +64,7 @@ inline fun <reified T : Annotation> ListableBeanFactory.getBeanNamesForAnnotatio
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Annotation> ListableBeanFactory.getBeansWithAnnotation(type: KClass<T>) =
|
||||
fun <T : Annotation> ListableBeanFactory.getBeansWithAnnotation(type: KClass<T>): MutableMap<String, Any> =
|
||||
getBeansWithAnnotation(type.java)
|
||||
|
||||
/**
|
||||
|
@ -74,7 +73,7 @@ fun <T : Annotation> ListableBeanFactory.getBeansWithAnnotation(type: KClass<T>)
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Annotation> ListableBeanFactory.getBeansWithAnnotation() =
|
||||
inline fun <reified T : Annotation> ListableBeanFactory.getBeansWithAnnotation(): MutableMap<String, Any> =
|
||||
getBeansWithAnnotation(T::class.java)
|
||||
|
||||
/**
|
||||
|
@ -83,7 +82,7 @@ inline fun <reified T : Annotation> ListableBeanFactory.getBeansWithAnnotation()
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Annotation> ListableBeanFactory.findAnnotationOnBean(beanName:String, type: KClass<T>) =
|
||||
fun <T : Annotation> ListableBeanFactory.findAnnotationOnBean(beanName:String, type: KClass<T>): Annotation? =
|
||||
findAnnotationOnBean(beanName, type.java)
|
||||
|
||||
/**
|
||||
|
@ -92,6 +91,6 @@ fun <T : Annotation> ListableBeanFactory.findAnnotationOnBean(beanName:String, t
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Annotation> ListableBeanFactory.findAnnotationOnBean(beanName:String) =
|
||||
inline fun <reified T : Annotation> ListableBeanFactory.findAnnotationOnBean(beanName:String): Annotation? =
|
||||
findAnnotationOnBean(beanName, T::class.java)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -12,9 +12,8 @@ import kotlin.reflect.KClass
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> GenericApplicationContext.registerBean(beanClass: KClass<T>,
|
||||
vararg customizers: BeanDefinitionCustomizer) {
|
||||
registerBean(beanClass.java, *customizers)
|
||||
fun <T : Any> GenericApplicationContext.registerBean(beanClass: KClass<T>, vararg customizers: BeanDefinitionCustomizer) {
|
||||
registerBean(beanClass.java, *customizers)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,7 +23,7 @@ fun <T : Any> GenericApplicationContext.registerBean(beanClass: KClass<T>,
|
|||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> GenericApplicationContext.registerBean(vararg customizers: BeanDefinitionCustomizer) {
|
||||
registerBean(T::class.java, *customizers)
|
||||
registerBean(T::class.java, *customizers)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,9 +32,8 @@ inline fun <reified T : Any> GenericApplicationContext.registerBean(vararg custo
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> GenericApplicationContext.registerBean(beanName: String, beanClass: KClass<T>,
|
||||
vararg customizers: BeanDefinitionCustomizer) {
|
||||
registerBean(beanName, beanClass.java, *customizers)
|
||||
fun <T : Any> GenericApplicationContext.registerBean(beanName: String, beanClass: KClass<T>, vararg customizers: BeanDefinitionCustomizer) {
|
||||
registerBean(beanName, beanClass.java, *customizers)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +43,7 @@ fun <T : Any> GenericApplicationContext.registerBean(beanName: String, beanClass
|
|||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> 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 <reified T : Any> GenericApplicationContext.registerBean(beanName: St
|
|||
*/
|
||||
inline fun <reified T : Any> 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 <reified T : Any> GenericApplicationContext.registerBean(
|
|||
*/
|
||||
inline fun <reified T : Any> 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 <reified T : Any> 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)
|
||||
|
||||
|
|
|
@ -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 <reified T: Any> RestOperations.getForObject(url: String, vararg uriVariables: Any) =
|
||||
inline fun <reified T: Any> RestOperations.getForObject(url: String, vararg uriVariables: Any): T =
|
||||
getForObject(url, T::class.java, *uriVariables)
|
||||
|
||||
/**
|
||||
|
@ -25,7 +26,7 @@ inline fun <reified T: Any> RestOperations.getForObject(url: String, vararg uriV
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.getForObject(url: String, uriVariables: Map<String, Any?>) =
|
||||
inline fun <reified T: Any> RestOperations.getForObject(url: String, uriVariables: Map<String, Any?>): T =
|
||||
getForObject(url, T::class.java, uriVariables)
|
||||
|
||||
/**
|
||||
|
@ -36,7 +37,7 @@ inline fun <reified T: Any> RestOperations.getForObject(url: String, uriVariable
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.getForObject(url: URI) =
|
||||
inline fun <reified T: Any> RestOperations.getForObject(url: URI): T =
|
||||
getForObject(url, T::class.java)
|
||||
|
||||
/**
|
||||
|
@ -47,7 +48,7 @@ inline fun <reified T: Any> RestOperations.getForObject(url: URI) =
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.getForEntity(url: String, vararg uriVariables: Any) =
|
||||
inline fun <reified T: Any> RestOperations.getForEntity(url: String, vararg uriVariables: Any): ResponseEntity<T> =
|
||||
getForEntity(url, T::class.java, *uriVariables)
|
||||
|
||||
/**
|
||||
|
@ -58,7 +59,7 @@ inline fun <reified T: Any> RestOperations.getForEntity(url: String, vararg uriV
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, vararg uriVariables: Any) =
|
||||
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, vararg uriVariables: Any): T =
|
||||
postForObject(url, request, T::class.java, *uriVariables)
|
||||
|
||||
/**
|
||||
|
@ -69,7 +70,7 @@ inline fun <reified T: Any> RestOperations.postForObject(url: String, request: A
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, uriVariables: Map<String, *>) =
|
||||
inline fun <reified T: Any> RestOperations.postForObject(url: String, request: Any, uriVariables: Map<String, *>): T =
|
||||
postForObject(url, request, T::class.java, uriVariables)
|
||||
|
||||
/**
|
||||
|
@ -78,7 +79,7 @@ inline fun <reified T: Any> RestOperations.postForObject(url: String, request: A
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.postForObject(url: URI, request: Any) =
|
||||
inline fun <reified T: Any> RestOperations.postForObject(url: URI, request: Any): T =
|
||||
postForObject(url, request, T::class.java)
|
||||
|
||||
/**
|
||||
|
@ -89,7 +90,7 @@ inline fun <reified T: Any> RestOperations.postForObject(url: URI, request: Any)
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, vararg uriVariables: Any) =
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, vararg uriVariables: Any): ResponseEntity<T> =
|
||||
postForEntity(url, request, T::class.java, *uriVariables)
|
||||
|
||||
/**
|
||||
|
@ -100,7 +101,7 @@ inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: A
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, uriVariables: Map<String, *>) =
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: Any, uriVariables: Map<String, *>): ResponseEntity<T> =
|
||||
postForEntity(url, request, T::class.java, uriVariables)
|
||||
|
||||
/**
|
||||
|
@ -111,7 +112,7 @@ inline fun <reified T: Any> RestOperations.postForEntity(url: String, request: A
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: URI, request: Any) =
|
||||
inline fun <reified T: Any> RestOperations.postForEntity(url: URI, request: Any): ResponseEntity<T> =
|
||||
postForEntity(url, request, T::class.java)
|
||||
|
||||
/**
|
||||
|
@ -122,7 +123,7 @@ inline fun <reified T: Any> RestOperations.postForEntity(url: URI, request: Any)
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, vararg uriVariables: Any) =
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, vararg uriVariables: Any): ResponseEntity<T> =
|
||||
exchange(url, method, requestEntity, T::class.java, *uriVariables)
|
||||
|
||||
/**
|
||||
|
@ -133,7 +134,7 @@ inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMet
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, uriVariables: Map<String, *>) =
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMethod, requestEntity: HttpEntity<*>, uriVariables: Map<String, *>): ResponseEntity<T> =
|
||||
exchange(url, method, requestEntity, T::class.java, uriVariables)
|
||||
|
||||
/**
|
||||
|
@ -144,7 +145,7 @@ inline fun <reified T: Any> RestOperations.exchange(url: String, method: HttpMet
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: URI, method: HttpMethod, requestEntity: HttpEntity<*>) =
|
||||
inline fun <reified T: Any> RestOperations.exchange(url: URI, method: HttpMethod, requestEntity: HttpEntity<*>): ResponseEntity<T> =
|
||||
exchange(url, method, requestEntity, T::class.java)
|
||||
|
||||
/**
|
||||
|
@ -155,5 +156,5 @@ inline fun <reified T: Any> RestOperations.exchange(url: URI, method: HttpMethod
|
|||
* @since 5.0
|
||||
*/
|
||||
@Throws(RestClientException::class)
|
||||
inline fun <reified T: Any> RestOperations.exchange(requestEntity: RequestEntity<*>) =
|
||||
inline fun <reified T: Any> RestOperations.exchange(requestEntity: RequestEntity<*>): ResponseEntity<T> =
|
||||
exchange(requestEntity, T::class.java)
|
||||
|
|
|
@ -11,7 +11,7 @@ import kotlin.reflect.KClass
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> toMono() : BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
||||
inline fun <reified T : Any> toMono(): BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
||||
BodyExtractors.toMono(T::class.java)
|
||||
|
||||
/**
|
||||
|
@ -20,7 +20,7 @@ inline fun <reified T : Any> toMono() : BodyExtractor<Mono<T>, ReactiveHttpInput
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> toMono(elementClass: KClass<T>) : BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
||||
fun <T : Any> toMono(elementClass: KClass<T>): BodyExtractor<Mono<T>, ReactiveHttpInputMessage> =
|
||||
BodyExtractors.toMono(elementClass.java)
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ fun <T : Any> toMono(elementClass: KClass<T>) : BodyExtractor<Mono<T>, ReactiveH
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> toFlux() : BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
||||
inline fun <reified T : Any> toFlux(): BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
||||
BodyExtractors.toFlux(T::class.java)
|
||||
|
||||
/**
|
||||
|
@ -38,5 +38,5 @@ inline fun <reified T : Any> toFlux() : BodyExtractor<Flux<T>, ReactiveHttpInput
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> toFlux(elementClass: KClass<T>) : BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
||||
fun <T : Any> toFlux(elementClass: KClass<T>): BodyExtractor<Flux<T>, ReactiveHttpInputMessage> =
|
||||
BodyExtractors.toFlux(elementClass.java)
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.http.server.reactive.ServerHttpResponse
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Publisher<S>, reified S : Any> fromPublisher(publisher: T) : BodyInserter<T, ReactiveHttpOutputMessage> =
|
||||
inline fun <reified T : Publisher<S>, reified S : Any> fromPublisher(publisher: T): BodyInserter<T, ReactiveHttpOutputMessage> =
|
||||
BodyInserters.fromPublisher(publisher, S::class.java)
|
||||
|
||||
/**
|
||||
|
@ -19,5 +19,5 @@ inline fun <reified T : Publisher<S>, reified S : Any> fromPublisher(publisher:
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Publisher<S>, reified S : Any> fromServerSentEvents(publisher: T) : BodyInserter<T, ServerHttpResponse> =
|
||||
inline fun <reified T : Publisher<S>, reified S : Any> fromServerSentEvents(publisher: T): BodyInserter<T, ServerHttpResponse> =
|
||||
BodyInserters.fromServerSentEvents(publisher, S::class.java)
|
||||
|
|
|
@ -11,7 +11,7 @@ import kotlin.reflect.KClass
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> ClientResponse.bodyToMono(type: KClass<T>) : Mono<T> = bodyToMono(type.java)
|
||||
fun <T : Any> ClientResponse.bodyToMono(type: KClass<T>): Mono<T> = bodyToMono(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [ClientResponse.bodyToMono] providing a `bodyToMono<Foo>()` variant.
|
||||
|
@ -19,7 +19,7 @@ fun <T : Any> ClientResponse.bodyToMono(type: KClass<T>) : Mono<T> = bodyToMono(
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> ClientResponse.bodyToMono() = bodyToMono(T::class.java)
|
||||
inline fun <reified T : Any> ClientResponse.bodyToMono(): Mono<T> = bodyToMono(T::class.java)
|
||||
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ inline fun <reified T : Any> ClientResponse.bodyToMono() = bodyToMono(T::class.j
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> ClientResponse.bodyToFlux(type: KClass<T>) : Flux<T> = bodyToFlux(type.java)
|
||||
fun <T : Any> ClientResponse.bodyToFlux(type: KClass<T>): Flux<T> = bodyToFlux(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [ClientResponse.bodyToFlux] providing a `bodyToFlux<Foo>()` variant.
|
||||
|
@ -36,4 +36,4 @@ fun <T : Any> ClientResponse.bodyToFlux(type: KClass<T>) : Flux<T> = bodyToFlux(
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> ClientResponse.bodyToFlux() = bodyToFlux(T::class.java)
|
||||
inline fun <reified T : Any> ClientResponse.bodyToFlux(): Flux<T> = bodyToFlux(T::class.java)
|
||||
|
|
|
@ -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 <reified T : Any, S : Publisher<T>> WebClient.RequestBodySpec.body(publisher: S) =
|
||||
body(publisher, T::class.java)
|
||||
inline fun <reified T : Any, S : Publisher<T>> WebClient.RequestBodySpec.body(publisher: S):
|
||||
Mono<ClientResponse> = body(publisher, T::class.java)
|
||||
|
|
|
@ -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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
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<ServerResponse>) {
|
||||
routes += RouterFunctions.route(RequestPredicates.path(this), HandlerFunction { f(it) })
|
||||
|
|
|
@ -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 <T : Any> ServerRequest.bodyToMono(type: KClass<T>) = bodyToMono(type.java)
|
||||
fun <T : Any> ServerRequest.bodyToMono(type: KClass<T>): Mono<T> = bodyToMono(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [ServerRequest.bodyToMono] providing a `bodyToMono<Foo>()` variant.
|
||||
|
@ -17,7 +19,7 @@ fun <T : Any> ServerRequest.bodyToMono(type: KClass<T>) = bodyToMono(type.java)
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> ServerRequest.bodyToMono() = bodyToMono(T::class.java)
|
||||
inline fun <reified T : Any> ServerRequest.bodyToMono(): Mono<T> = bodyToMono(T::class.java)
|
||||
|
||||
/**
|
||||
* Extension for [ServerRequest.bodyToFlux] providing a [KClass] based variant.
|
||||
|
@ -25,7 +27,7 @@ inline fun <reified T : Any> ServerRequest.bodyToMono() = bodyToMono(T::class.ja
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> ServerRequest.bodyToFlux(type: KClass<T>) = bodyToFlux(type.java)
|
||||
fun <T : Any> ServerRequest.bodyToFlux(type: KClass<T>): Flux<T> = bodyToFlux(type.java)
|
||||
|
||||
/**
|
||||
* Extension for [ServerRequest.bodyToFlux] providing a `bodyToFlux<Foo>()` variant.
|
||||
|
@ -33,4 +35,4 @@ fun <T : Any> ServerRequest.bodyToFlux(type: KClass<T>) = bodyToFlux(type.java)
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> ServerRequest.bodyToFlux() = bodyToFlux(T::class.java)
|
||||
inline fun <reified T : Any> ServerRequest.bodyToFlux(): Flux<T> = bodyToFlux(T::class.java)
|
||||
|
|
|
@ -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<T>)` variant.
|
||||
|
@ -8,4 +9,4 @@ import org.reactivestreams.Publisher
|
|||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
inline fun <reified T : Any> ServerResponse.BodyBuilder.body(publisher: Publisher<T>) = body(publisher, T::class.java)
|
||||
inline fun <reified T : Any> ServerResponse.BodyBuilder.body(publisher: Publisher<T>): Mono<ServerResponse> = body(publisher, T::class.java)
|
Loading…
Reference in New Issue