This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,45 @@ The following three methods are the main ways to get the `method reference`.
121
121
- from ` factory method ` in ` companion object ` : ` (Dst)::factoryMethod `
122
122
- from instance method in ` this ` scope: ` this::factoryMethod `
123
123
124
+ ### Initialization from KClass
125
+ The ` KRowMapper ` can be initialized by ` KClass ` .
126
+ By default, the primary constructor is the target of the call.
127
+
128
+ ``` kotlin
129
+ data class Dst (...)
130
+
131
+ val mapper: KRowMapper <Dst > = KRowMapper (Dst ::class )
132
+ ```
133
+
134
+ #### Specifying the target of a call by KConstructor annotation
135
+ When you initialize from the ` KClass ` , you can use the ` KConstructor ` annotation and to specify the function to be called.
136
+
137
+ In the following example, the ` secondary constructor ` is called.
138
+
139
+ ``` kotlin
140
+ data class Dst (...) {
141
+ @KConstructor
142
+ constructor (.. .) : this (.. .)
143
+ }
144
+
145
+ val mapper: KRowMapper <Dst > = KRowMapper (Dst ::class )
146
+ ```
147
+
148
+ Similarly, the following example calls the ` factory method ` .
149
+
150
+ ``` kotlin
151
+ data class Dst (...) {
152
+ companion object {
153
+ @KConstructor
154
+ fun factory (...): Dst {
155
+ .. .
156
+ }
157
+ }
158
+ }
159
+
160
+ val mapper: KRowMapper <Dst > = KRowMapper (Dst ::class )
161
+ ```
162
+
124
163
## Usage
125
164
### Deserialize column
126
165
` KRowMapper ` provides a deserialization function for the acquisition results of three patterns.
You can’t perform that action at this time.
0 commit comments