You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/object-mapping.adoc
+10-8Lines changed: 10 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -232,16 +232,16 @@ Kotlin classes are supported to be instantiated , all classes are immutable by d
232
232
Consider the following `data` class `Person`:
233
233
234
234
====
235
-
[source,java]
235
+
[source,kotlin]
236
236
----
237
237
data class Person(val id: String, val name: String)
238
238
----
239
239
====
240
240
241
-
The class above compiles to a typical class with an explicit constructor.We can customize this class by adding another constructor and annotate it with `@PersistenceConstructor` to indicate a constructor preference:
241
+
The class above compiles to a typical class with an explicit constructor.We can customize this class by adding another constructor and annotate it with `@PersistenceConstructor` to indicate a constructor preference:
242
242
243
243
====
244
-
[source,java]
244
+
[source,kotlin]
245
245
----
246
246
data class Person(var id: String, val name: String) {
247
247
@@ -252,10 +252,10 @@ data class Person(var id: String, val name: String) {
252
252
====
253
253
254
254
Kotlin supports parameter optionality by allowing default values to be used if a parameter is not provided.
255
-
When Spring Data detects a constructor with parameter defaulting, then it leaves these parameters absent if the data store does not provide a value (or simply returns `null`) so Kotlin can apply parameter defaulting.Consider the following class that applies parameter defaulting for `name`
255
+
When Spring Data detects a constructor with parameter defaulting, then it leaves these parameters absent if the data store does not provide a value (or simply returns `null`) so Kotlin can apply parameter defaulting.Consider the following class that applies parameter defaulting for `name`
256
256
257
257
====
258
-
[source,java]
258
+
[source,kotlin]
259
259
----
260
260
data class Person(var id: String, val name: String = "unknown")
261
261
----
@@ -265,13 +265,15 @@ Every time the `name` parameter is either not part of the result or its value is
265
265
266
266
=== Property population of Kotlin data classes
267
267
268
-
In Kotlin, all classes are immutable by default and require explicit property declarations to define mutable properties. Consider the following `data` class `Person`:
268
+
In Kotlin, all classes are immutable by default and require explicit property declarations to define mutable properties.
269
+
Consider the following `data` class `Person`:
269
270
270
271
====
271
-
[source,java]
272
+
[source,kotlin]
272
273
----
273
274
data class Person(val id: String, val name: String)
274
275
----
275
276
====
276
277
277
-
This class is effectively immutable. It allows to create new instances as Kotlin generates a `copy(…)` method that creates new object instances copying all property values from the existing object and applying property values provided as arguments to the method.
278
+
This class is effectively immutable.
279
+
It allows creating new instances as Kotlin generates a `copy(…)` method that creates new object instances copying all property values from the existing object and applying property values provided as arguments to the method.
0 commit comments