Improve Kotlin extensions doc about type erasure

Since type erasure can be fixed only when using
ParameterizedTypeReference based Java methods, RestOperations and
WebFlux API documentation should be updated to specify which extensions
are subject to type erasure, and which are not.

Issue: SPR-16273
This commit is contained in:
sdeleuze
2017-12-27 16:50:19 +01:00
parent 8fc16fc937
commit deac8e556e
5 changed files with 96 additions and 49 deletions

View File

@@ -23,7 +23,8 @@ import reactor.core.publisher.Mono
/**
* Extension for [ClientResponse.bodyToMono] providing a `bodyToMono<Foo>()` variant
* leveraging Kotlin reified type parameters.
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0
@@ -33,7 +34,8 @@ inline fun <reified T : Any> ClientResponse.bodyToMono(): Mono<T> =
/**
* Extension for [ClientResponse.bodyToFlux] providing a `bodyToFlux<Foo>()` variant
* leveraging Kotlin reified type parameters.
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0
@@ -43,7 +45,8 @@ inline fun <reified T : Any> ClientResponse.bodyToFlux(): Flux<T> =
/**
* Extension for [ClientResponse.toEntity] providing a `toEntity<Foo>()` variant
* leveraging Kotlin reified type parameters.
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0
@@ -53,7 +56,8 @@ inline fun <reified T : Any> ClientResponse.toEntity(): Mono<ResponseEntity<T>>
/**
* Extension for [ClientResponse.toEntityList] providing a `bodyToEntityList<Foo>()` variant
* leveraging Kotlin reified type parameters.
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0

View File

@@ -25,7 +25,8 @@ import reactor.core.publisher.Mono
/**
* Extension for [WebClient.RequestBodySpec.body] providing a `body<Foo>()` variant
* leveraging Kotlin reified type parameters.
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0
@@ -36,7 +37,8 @@ inline fun <reified T : Any, S : Publisher<T>> RequestBodySpec.body(publisher: S
/**
* Extension for [WebClient.ResponseSpec.bodyToMono] providing a `bodyToMono<Foo>()` variant
* leveraging Kotlin reified type parameters.
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0
@@ -47,7 +49,8 @@ inline fun <reified T : Any> WebClient.ResponseSpec.bodyToMono(): Mono<T> =
/**
* Extension for [WebClient.ResponseSpec.bodyToFlux] providing a `bodyToFlux<Foo>()` variant
* leveraging Kotlin reified type parameters.
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0

View File

@@ -22,7 +22,8 @@ import reactor.core.publisher.Mono
/**
* Extension for [ServerRequest.bodyToMono] providing a `bodyToMono<Foo>()` variant
* leveraging Kotlin reified type parameters.
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0
@@ -32,7 +33,8 @@ inline fun <reified T : Any> ServerRequest.bodyToMono(): Mono<T> =
/**
* Extension for [ServerRequest.bodyToFlux] providing a `bodyToFlux<Foo>()` variant
* leveraging Kotlin reified type parameters.
* leveraging Kotlin reified type parameters. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0

View File

@@ -22,7 +22,9 @@ import org.springframework.http.MediaType
import reactor.core.publisher.Mono
/**
* Extension for [ServerResponse.BodyBuilder.body] providing a `body(Publisher<T>)` variant.
* Extension for [ServerResponse.BodyBuilder.body] providing a `body(Publisher<T>)`
* variant. This extension is not subject to type erasure and retains actual generic
* type arguments.
*
* @author Sebastien Deleuze
* @since 5.0
@@ -31,7 +33,9 @@ inline fun <reified T : Any> ServerResponse.BodyBuilder.body(publisher: Publishe
body(publisher, object : ParameterizedTypeReference<T>() {})
/**
* Extension for [ServerResponse.BodyBuilder.body] providing a `bodyToServerSentEvents(Publisher<T>)` variant.
* Extension for [ServerResponse.BodyBuilder.body] providing a
* `bodyToServerSentEvents(Publisher<T>)` variant. This extension is not subject to type
* erasure and retains actual generic type arguments.
*
* @author Sebastien Deleuze
* @since 5.0