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

Commit 4f2a569

Browse files
committed
ダミーは共通で使いたいため切り出し
1 parent 9bbe4ab commit 4f2a569

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/main/kotlin/com/mapk/kmapper/BoundParameterForMap.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ internal sealed class BoundParameterForMap<S> {
3838
private val kMapper: KMapper<*>
3939
) : BoundParameterForMap<S>() {
4040
// 1引数で呼び出すとMap/Pairが適切に処理されないため、2引数目にダミーを噛ませている
41-
override fun map(src: S): Any? = kMapper.map(propertyGetter.invoke(src), dummy)
42-
43-
companion object {
44-
private val dummy = "" to null
45-
}
41+
override fun map(src: S): Any? = kMapper.map(propertyGetter.invoke(src), PARAMETER_DUMMY)
4642
}
4743

4844
private class UseBoundKMapper<S : Any, T : Any>(

src/main/kotlin/com/mapk/kmapper/ParameterUtils.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ private fun <T : Any> convertersFromCompanionObject(clazz: KClass<T>): Set<Pair<
5252
// 引数の型がconverterに対して入力可能ならconverterを返す
5353
internal fun <T : Any> Set<Pair<KClass<*>, KFunction<T>>>.getConverter(input: KClass<out T>): KFunction<T>? =
5454
this.find { (key, _) -> input.isSubclassOf(key) }?.second
55+
56+
// 再帰的マッピング時にKMapperでマップする場合、引数の数が1つだと正常にマッピングが機能しないため、2引数にするために用いるダミー
57+
internal val PARAMETER_DUMMY = "" to null

0 commit comments

Comments
 (0)