#199 - Add documentation for Kotlin support.

This commit is contained in:
Mark Paluch
2019-09-27 16:04:21 +02:00
parent 35b0fec05a
commit 53121b49a4
2 changed files with 32 additions and 0 deletions

View File

@@ -36,4 +36,8 @@ include::reference/r2dbc-repositories.adoc[leveloffset=+1]
include::reference/r2dbc-connections.adoc[leveloffset=+1]
include::reference/r2dbc-initialization.adoc[leveloffset=+1]
include::reference/mapping.adoc[leveloffset=+1]
include::reference/kotlin.adoc[leveloffset=+1]

View File

@@ -0,0 +1,28 @@
include::../{spring-data-commons-docs}/kotlin.adoc[]
include::../{spring-data-commons-docs}/kotlin-extensions.adoc[leveloffset=+1]
To retrieve a list of `SWCharacter` objects in Java, you would normally write the following:
[source,java]
----
Flux<SWCharacter> characters = client.select().from(SWCharacter.class).fetch().all();
----
With Kotlin and the Spring Data extensions, you can instead write the following:
[source,kotlin]
----
val characters = client.select().from<SWCharacter>().fetch().all()
// or (both are equivalent)
val characters : Flux<SWCharacter> = client.select().from().fetch().all()
----
As in Java, `characters` in Kotlin is strongly typed, but Kotlin's clever type inference allows for shorter syntax.
Spring Data R2DBC provides the following extensions:
* Reified generics support for `DatabaseClient` and `Criteria`.
* <<kotlin.coroutines>> extensions for `DatabaseClient`.
include::../{spring-data-commons-docs}/kotlin-coroutines.adoc[leveloffset=+1]