Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit 8728541

Browse files
committed
引数読み出しの対象・引数のセットアップ
1 parent ef8d5a1 commit 8728541

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,3 +581,33 @@ data class Src(
581581
val param2: Int
582582
)
583583
```
584+
585+
## Setting Up Arguments
586+
587+
### Target for argument reading
588+
The `KMapper` can read the `public` field of an object, or the properties of `Pair<String, Any?>` and `Map<String, Any?>`.
589+
590+
### Setting Up Arguments
591+
The `KMapper` performs the setup process if the value is not `null`.
592+
In the setup process, first of all, `parameterClazz.isSuperclassOf(inputClazz)` is used to check if the input can be set as an argument or not, and if not, the conversion described later is performed and the result is used as an argument.
593+
594+
If the value is `null`, the `KParameterRequireNonNull` annotation is checked, and if it is set, the setup process is skipped, otherwise `null` is used as the argument.
595+
596+
If the `KUseDefaultArgument` annotation is set or all inputs are skipped by the `KParameterRequireNonNull` annotation, the default argument is used.
597+
If the default argument is not available at this time, a runtime error occurs.
598+
599+
#### Conversion of arguments
600+
`KMapper` performs conversion and checking in the following order.
601+
602+
**1. Checking the specification of the conversion process by annotation**
603+
First of all, it checks for conversions specified by the `KConvertBy` and `KConverter` annotations for the class of the input.
604+
605+
**2. Confirmation of conversion to Enum**
606+
If the input is a `String` and the argument is an `Enum`, the function tries to convert the input to an `Enum` with the corresponding `name`.
607+
608+
**3. Confirmation of conversion to string**
609+
If the argument is `String`, the input will be `toString`.
610+
611+
**4. Conversion using the mapper class**
612+
If the transformation does not meet the criteria so far, a mapping process is performed using a mapper class.
613+
For this mapping process, `PlainKMapper` is used for `PlainKMapper`, and `BoundKMapper` is used for others.

0 commit comments

Comments
 (0)