@@ -16,15 +16,15 @@ internal class ParameterForMap<T : Any> private constructor(val param: KParamete
1616 clazz.java
1717 }
1818 // リストの長さが小さいと期待されるためこの形で実装しているが、理想的にはmap的なものが使いたい
19- private val creators : Set <Pair <KClass <* >, KFunction <T >>> by lazy {
20- creatorsFromConstructors (clazz) + creatorsFromStaticMethods (
19+ private val converters : Set <Pair <KClass <* >, KFunction <T >>> by lazy {
20+ convertersFromConstructors (clazz) + convertersFromStaticMethods (
2121 clazz
22- ) + creatorsFromCompanionObject (clazz)
22+ ) + convertersFromCompanionObject (clazz)
2323 }
2424
25- // 引数の型がcreatorに対して入力可能ならcreatorを返す
26- fun <R : Any > getCreator (input : KClass <out R >): KFunction <T >? =
27- creators .find { (key, _) -> input.isSubclassOf(key) }?.second
25+ // 引数の型がconverterに対して入力可能ならconverterを返す
26+ fun <R : Any > getConverter (input : KClass <out R >): KFunction <T >? =
27+ converters .find { (key, _) -> input.isSubclassOf(key) }?.second
2828
2929 companion object {
3030 fun newInstance (param : KParameter ): ParameterForMap <* > {
@@ -42,19 +42,19 @@ private fun <T> Collection<KFunction<T>>.getConverterMapFromFunctions(): Set<Pai
4242 }.toSet()
4343}
4444
45- private fun <T : Any > creatorsFromConstructors (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
45+ private fun <T : Any > convertersFromConstructors (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
4646 return clazz.constructors.getConverterMapFromFunctions()
4747}
4848
4949@Suppress(" UNCHECKED_CAST" )
50- private fun <T : Any > creatorsFromStaticMethods (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
50+ private fun <T : Any > convertersFromStaticMethods (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
5151 val staticFunctions: Collection <KFunction <T >> = clazz.staticFunctions as Collection <KFunction <T >>
5252
5353 return staticFunctions.getConverterMapFromFunctions()
5454}
5555
5656@Suppress(" UNCHECKED_CAST" )
57- private fun <T : Any > creatorsFromCompanionObject (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
57+ private fun <T : Any > convertersFromCompanionObject (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
5858 return clazz.companionObjectInstance?.let { companionObject ->
5959 companionObject::class .functions
6060 .filter { it.annotations.any { annotation -> annotation is KConverter } }
0 commit comments