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

Commit 462e0d3

Browse files
committed
Pairをsrcにできなかった問題を修正
Any要求のmapが別に居ることが原因 そっちを消しても良かったが、vararg要求の方を経由させると非効率なので、新設する形で対応
1 parent 4816193 commit 462e0d3

File tree

1 file changed

+6
-0
lines changed
  • src/main/kotlin/com/wrongwrong/mapk/core

1 file changed

+6
-0
lines changed

src/main/kotlin/com/wrongwrong/mapk/core/KMapper.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ class KMapper<T : Any>(private val function: KFunction<T>, propertyNameConverter
3939
}.let { function.callBy(it) }
4040
}
4141

42+
fun map(srcPair: Pair<String, Any?>): T = parameters
43+
.single { it.name == srcPair.first }
44+
.let {
45+
function.callBy(mapOf(it.param to srcPair.second?.let { value -> mapObject(it, value) }))
46+
}
47+
4248
fun map(src: Any): T {
4349
val srcMap: Map<String, KProperty1.Getter<*, *>> =
4450
src::class.memberProperties.filterTargets().associate { property ->

0 commit comments

Comments
 (0)