Skip to content

Commit c62bc6f

Browse files
DATAMONGO-1584 - Polishing.
Original Pull Request: #407
1 parent 37ab48e commit c62bc6f

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

src/main/asciidoc/kotlin-coroutines.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[[kotlin.coroutines]]
22
= Coroutines
33

4-
Kotlin https://kotlinlang.org/docs/reference/coroutines-overview.html[Coroutines] are Kotlin lightweight threads allowing to write non-blocking code imperatively.
5-
On language side, suspending functions provides an abstraction for asynchronous operations while on library side https://github.com/Kotlin/kotlinx.coroutines[kotlinx.coroutines] provides functions like https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html[`async { }`] and types like https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[`Flow`].
4+
Kotlin https://kotlinlang.org/docs/reference/coroutines-overview.html[Coroutines] are lightweight threads allowing to write non-blocking code imperatively.
5+
On language side, `suspend` functions provides an abstraction for asynchronous operations while on library side https://github.com/Kotlin/kotlinx.coroutines[kotlinx.coroutines] provides functions like https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html[`async { }`] and types like https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[`Flow`].
66

77
Spring Data modules provide support for Coroutines on the following scope:
88

@@ -29,7 +29,7 @@ Coroutines support is enabled when `kotlinx-coroutines-core` and `kotlinx-corout
2929
----
3030
====
3131

32-
Version `1.3.0` and above are supported.
32+
NOTE: Supported versions `1.3.0` and above.
3333

3434
[[kotlin.coroutines.reactive]]
3535
== How Reactive translates to Coroutines?

src/main/asciidoc/kotlin-extensions.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33

44
Kotlin https://kotlinlang.org/docs/reference/extensions.html[extensions] provide the ability to extend existing classes with additional functionality. Spring Data Kotlin APIs use these extensions to add new Kotlin-specific conveniences to existing Spring APIs.
55

6-
NOTE: Keep in mind that Kotlin extensions need to be imported to be used.
6+
[NOTE]
7+
====
8+
Keep in mind that Kotlin extensions need to be imported to be used.
79
Similar to static imports, an IDE should automatically suggest the import in most cases.
10+
====
811

912
For example, https://kotlinlang.org/docs/reference/inline-functions.html#reified-type-parameters[Kotlin reified type parameters] provide a workaround for JVM https://docs.oracle.com/javase/tutorial/java/generics/erasure.html[generics type erasure], and Spring Data provides some extensions to take advantage of this feature.
1013
This allows for a better Kotlin API.

src/main/asciidoc/kotlin.adoc

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,40 @@
33

44
https://kotlinlang.org[Kotlin] is a statically typed language that targets the JVM (and other platforms) which allows writing concise and elegant code while providing excellent https://kotlinlang.org/docs/reference/java-interop.html[interoperability] with existing libraries written in Java.
55

6-
Spring Data provides first-class support for Kotlin and lets developers write Kotlin applications almost as if Spring Data was a Kotlin-native framework.
6+
Spring Data provides first-class support for Kotlin and lets developers write Kotlin applications almost as if Spring Data was a Kotlin native framework.
77

88
The easiest way to build a Spring application with Kotlin is to leverage Spring Boot and its https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-kotlin.html[dedicated Kotlin support].
9-
https://spring.io/guides/tutorials/spring-boot-kotlin/[This comprehensive tutorial] will teach you how to build Spring Boot applications with Kotlin using https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
9+
This comprehensive https://spring.io/guides/tutorials/spring-boot-kotlin/[tutorial] will teach you how to build Spring Boot applications with Kotlin using https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
1010

1111
[[kotlin.requirements]]
1212
== Requirements
1313

1414
Spring Data supports Kotlin 1.3 and requires https://bintray.com/bintray/jcenter/org.jetbrains.kotlin%3Akotlin-stdlib[`kotlin-stdlib`] (or one of its variants, such as https://bintray.com/bintray/jcenter/org.jetbrains.kotlin%3Akotlin-stdlib-jdk8[`kotlin-stdlib-jdk8`]) and https://bintray.com/bintray/jcenter/org.jetbrains.kotlin%3Akotlin-reflect[`kotlin-reflect`] to be present on the classpath.
15-
They are provided by default if you bootstrap a Kotlin project on https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
15+
Those are provided by default if you bootstrap a Kotlin project via https://start.spring.io/#!language=kotlin&type=gradle-project[start.spring.io].
1616

1717
[[kotlin.null-safety]]
18-
== Null-safety
18+
== Null Safety
1919

20-
One of Kotlin's key features is https://kotlinlang.org/docs/reference/null-safety.html[null-safety], which cleanly deals with `null` values at compile time rather than bumping into the famous `NullPointerException` at runtime.
21-
This makes applications safer through nullability declarations and expressing "`value or no value`" semantics without paying the cost of wrappers, such as `Optional`.
22-
(Kotlin allows using functional constructs with nullable values. See this https://www.baeldung.com/kotlin-null-safety[comprehensive guide to Kotlin null-safety].)
20+
One of Kotlin's key features is https://kotlinlang.org/docs/reference/null-safety.html[null safety], which cleanly deals with `null` values at compile time.
21+
This makes applications safer through nullability declarations and the expression of "`value or no value`" semantics without paying the cost of wrappers, such as `Optional`.
22+
(Kotlin allows using functional constructs with nullable values. See this https://www.baeldung.com/kotlin-null-safety[comprehensive guide to Kotlin null safety].)
2323

24-
Although Java does not let you express null-safety in its type-system, Spring Data API is annotated with JSR-305 tooling-friendly annotations declared in the `org.springframework.lang` package.
25-
By default, types from Java APIs used in Kotlin are recognized as https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types[platform types], for which null-checks are relaxed.
26-
https://kotlinlang.org/docs/reference/java-interop.html#jsr-305-support[Kotlin support for JSR-305 annotations] and Spring nullability annotations provide null-safety for the whole Spring Data API to Kotlin developers, with the advantage of dealing with `null`-related issues at compile time.
24+
Although Java does not let you express null safety in its type system, Spring Data API is annotated with https://jcp.org/en/jsr/detail?id=305[JSR-305] tooling friendly annotations declared in the `org.springframework.lang` package.
25+
By default, types from Java APIs used in Kotlin are recognized as https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types[platform types], for which null checks are relaxed.
26+
https://kotlinlang.org/docs/reference/java-interop.html#jsr-305-support[Kotlin support for JSR-305 annotations] and Spring nullability annotations provide null safety for the whole Spring Data API to Kotlin developers, with the advantage of dealing with `null` related issues at compile time.
2727

28+
See <<repositories.nullability>> how null safety applies to Spring Data Repositories.
29+
30+
[TIP]
31+
====
2832
You can configure JSR-305 checks by adding the `-Xjsr305` compiler flag with the following options: `-Xjsr305={strict|warn|ignore}`.
2933
30-
For kotlin versions 1.1+, the default behavior is the same as `-Xjsr305=warn`.
34+
For Kotlin versions 1.1+, the default behavior is the same as `-Xjsr305=warn`.
3135
The `strict` value is required take Spring Data API null-safety into account. Kotlin types inferred from Spring API but should be used with the knowledge that Spring API nullability declaration could evolve, even between minor releases and that more checks may be added in the future.
36+
====
3237

3338
NOTE: Generic type arguments, varargs, and array elements nullability are not supported yet, but should be in an upcoming release.
3439

35-
See <<repositories.nullability>> how Null-safety applies to Spring Data Repositories.
36-
3740
[[kotlin.mapping]]
3841
== Object Mapping
3942

0 commit comments

Comments
 (0)