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

Commit 82f9ff6

Browse files
committed
Use default arguments
1 parent 7ee81e3 commit 82f9ff6

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -443,27 +443,27 @@ data class Foo(
443443

444444
The transformation of the argument name is also applied to the alias set by `KParameterAlias`.
445445

446-
### Use default arguments
447-
`KRowMapper` supports `default arguments`.
448-
`Default arguments` are available in the following situations:
446+
#### Use default arguments
447+
The `KRowMapper` allows you to use default arguments in certain situations.
449448

450-
- When not referring to the acquisition result
451-
- When the acquisition result is `null`
452-
453-
As of `KRowMapper` 0.8, it does not support the use of `default argument` when columns cannot be obtained.
454-
455-
#### When not referring to the acquisition result
456-
When the `KUseDefaultArgument` `annotation` is added to the parameter,
457-
the `default argument` can be used forcibly without referring to the obtained result.
449+
##### Always use the default arguments
450+
If you don't want to use the value from the DB and always use the default argument, you can use the `KUseDefaultArgument` annotation.
458451

459452
```kotlin
460-
data class Dst(val fooId: Int, @param:KUseDefaultArgument val barValue: String = "default")
453+
class Foo(
454+
...,
455+
@KUseDefaultArgument
456+
val description: String = ""
457+
)
461458
```
462459

463-
#### When the acquisition result is null
464-
When `KParameterRequireNonNull` `annotation` is given to a parameter,
465-
the default argument can be used if the obtained result is `null`.
460+
##### Use default argument if the result is null
461+
If you want to use the default argument if the result is `null`, you can use the `KParameterRequireNonNull` annotation.
466462

467463
```kotlin
468-
data class Dst(val fooId: Int, @param:KParameterRequireNonNull val barValue: String = "default")
464+
class Foo(
465+
...,
466+
@KParameterRequireNonNull
467+
val description: String = ""
468+
)
469469
```

0 commit comments

Comments
 (0)