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

Commit bbea5e4

Browse files
committed
コンバータ検索処理を切り出し
1 parent d73374c commit bbea5e4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import kotlin.reflect.KClass
66
import kotlin.reflect.KFunction
77
import kotlin.reflect.full.companionObjectInstance
88
import kotlin.reflect.full.functions
9+
import kotlin.reflect.full.isSubclassOf
910
import kotlin.reflect.full.staticFunctions
1011
import kotlin.reflect.jvm.isAccessible
1112

@@ -47,3 +48,7 @@ private fun <T : Any> convertersFromCompanionObject(clazz: KClass<T>): Set<Pair<
4748
}.toSet()
4849
} ?: emptySet()
4950
}
51+
52+
// 引数の型がconverterに対して入力可能ならconverterを返す
53+
internal fun <T : Any> Set<Pair<KClass<*>, KFunction<T>>>.getConverter(input: KClass<out T>): KFunction<T>? =
54+
this.find { (key, _) -> input.isSubclassOf(key) }?.second

0 commit comments

Comments
 (0)