Specify explicitly Kotlin extensions return type
The main purpose is to specify nullability.
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user