Polish Kotlin source code style

This commit is contained in:
sdeleuze
2017-11-21 15:14:01 +01:00
parent 5843173567
commit 9f1d8517ba
27 changed files with 130 additions and 91 deletions

View File

@@ -21,7 +21,6 @@ import org.springframework.http.ResponseEntity
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
/**
* Extension for [ClientResponse.bodyToMono] providing a `bodyToMono<Foo>()` variant
* leveraging Kotlin reified type parameters.

View File

@@ -18,10 +18,11 @@ package org.springframework.web.reactive.function.client
import org.reactivestreams.Publisher
import org.springframework.core.ParameterizedTypeReference
import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec
import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
/**
* Extension for [WebClient.RequestBodySpec.body] providing a `body<Foo>()` variant
* leveraging Kotlin reified type parameters.
@@ -30,7 +31,7 @@ import reactor.core.publisher.Mono
* @since 5.0
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
inline fun <reified T : Any, S : Publisher<T>> WebClient.RequestBodySpec.body(publisher: S): WebClient.RequestHeadersSpec<*> =
inline fun <reified T : Any, S : Publisher<T>> RequestBodySpec.body(publisher: S): RequestHeadersSpec<*> =
body(publisher, object : ParameterizedTypeReference<T>() {})
/**

View File

@@ -21,10 +21,10 @@ import org.springframework.http.HttpMethod
import org.springframework.http.MediaType
import reactor.core.publisher.Mono
/**
* Allow to create easily a `RouterFunction<ServerResponse>` from a Kotlin router DSL based
* on the same building blocks than the Java one ([RouterFunction], [RequestPredicate], [HandlerFunction]).
* on the same building blocks than the Java one ([RouterFunction], [RequestPredicate],
* [HandlerFunction]).
*
* Example:
*
@@ -126,9 +126,9 @@ open class RouterFunctionDsl {
operator fun RequestPredicate.not(): RequestPredicate = this.negate()
/**
* Route to the given router function if the given request predicate applies. This method can be
* used to create *nested routes*, where a group of routes share a common path (prefix),
* header, or other request predicate.
* Route to the given router function if the given request predicate applies. This
* method can be used to create *nested routes*, where a group of routes share a
* common path (prefix), header, or other request predicate.
* @see RouterFunctions.nest
*/
fun RequestPredicate.nest(r: RouterFunctionDsl.() -> Unit) {
@@ -305,7 +305,8 @@ open class RouterFunctionDsl {
* @param headersPredicate a predicate that tests against the request headers
* @return a predicate that tests against the given header predicate
*/
fun headers(headersPredicate: (ServerRequest.Headers) -> Boolean): RequestPredicate = RequestPredicates.headers(headersPredicate)
fun headers(headersPredicate: (ServerRequest.Headers) -> Boolean): RequestPredicate =
RequestPredicates.headers(headersPredicate)
/**
* Route to the given handler function if the given method predicate applies.
@@ -364,7 +365,8 @@ open class RouterFunctionDsl {
* predicate.
* @see RequestPredicates.pathExtension
*/
fun pathExtension(predicate: (String) -> Boolean): RequestPredicate = RequestPredicates.pathExtension(predicate)
fun pathExtension(predicate: (String) -> Boolean): RequestPredicate =
RequestPredicates.pathExtension(predicate)
/**
* Route to the given handler function if the given queryParam predicate applies.
@@ -382,7 +384,8 @@ open class RouterFunctionDsl {
* @return a predicate that matches the given predicate against the query parameter of the given name
* @see ServerRequest#queryParam(String)
*/
fun queryParam(name: String, predicate: (String) -> Boolean): RequestPredicate = RequestPredicates.queryParam(name, predicate)
fun queryParam(name: String, predicate: (String) -> Boolean): RequestPredicate =
RequestPredicates.queryParam(name, predicate)
/**
* Route to the given handler function if the given request predicate applies.

View File

@@ -20,7 +20,6 @@ import org.springframework.core.ParameterizedTypeReference
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
/**
* Extension for [ServerRequest.bodyToMono] providing a `bodyToMono<Foo>()` variant
* leveraging Kotlin reified type parameters.

View File

@@ -26,7 +26,7 @@ import org.mockito.junit.MockitoJUnitRunner
import org.springframework.core.ParameterizedTypeReference
/**
* Mock object based tests for [ClientResponse] Kotlin extensions
* Mock object based tests for [ClientResponse] Kotlin extensions.
*
* @author Sebastien Deleuze
*/

View File

@@ -28,7 +28,7 @@ import reactor.test.StepVerifier
import java.net.URI
/**
* Tests for [RouterFunction] Kotlin DSL
* Tests for [RouterFunction] Kotlin DSL.
*
* @author Sebastien Deleuze
*/
@@ -52,7 +52,11 @@ class RouterFunctionDslTests {
@Test
fun acceptAndPOST() {
val request = builder().method(POST).uri(URI("/api/foo/")).header(ACCEPT, APPLICATION_JSON_VALUE).build()
val request = builder()
.method(POST)
.uri(URI("/api/foo/"))
.header(ACCEPT, APPLICATION_JSON_VALUE)
.build()
StepVerifier.create(sampleRouter().route(request))
.expectNextCount(1)
.verifyComplete()

View File

@@ -28,7 +28,7 @@ import org.springframework.web.reactive.function.server.bodyToFlux
import org.springframework.web.reactive.function.server.bodyToMono
/**
* Mock object based tests for [ServerRequest] Kotlin extensions
* Mock object based tests for [ServerRequest] Kotlin extensions.
*
* @author Sebastien Deleuze
*/