@@ -9,7 +9,10 @@ import kotlin.reflect.full.functions
99import kotlin.reflect.full.staticFunctions
1010import kotlin.reflect.jvm.isAccessible
1111
12- internal fun <T > Collection<KFunction<T>>.getConverterMapFromFunctions (): Set <Pair <KClass <* >, KFunction<T>>> {
12+ internal fun <T : Any > KClass<T>.getConverters (): Set <Pair <KClass <* >, KFunction<T>>> =
13+ convertersFromConstructors(this ) + convertersFromStaticMethods(this ) + convertersFromCompanionObject(this )
14+
15+ private fun <T > Collection<KFunction<T>>.getConverterMapFromFunctions (): Set <Pair <KClass <* >, KFunction<T>>> {
1316 return filter { it.annotations.any { annotation -> annotation is KConverter } }
1417 .map { func ->
1518 func.isAccessible = true
@@ -18,19 +21,19 @@ internal fun <T> Collection<KFunction<T>>.getConverterMapFromFunctions(): Set<Pa
1821 }.toSet()
1922}
2023
21- internal fun <T : Any > convertersFromConstructors (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
24+ private fun <T : Any > convertersFromConstructors (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
2225 return clazz.constructors.getConverterMapFromFunctions()
2326}
2427
2528@Suppress(" UNCHECKED_CAST" )
26- internal fun <T : Any > convertersFromStaticMethods (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
29+ private fun <T : Any > convertersFromStaticMethods (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
2730 val staticFunctions: Collection <KFunction <T >> = clazz.staticFunctions as Collection <KFunction <T >>
2831
2932 return staticFunctions.getConverterMapFromFunctions()
3033}
3134
3235@Suppress(" UNCHECKED_CAST" )
33- internal fun <T : Any > convertersFromCompanionObject (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
36+ private fun <T : Any > convertersFromCompanionObject (clazz : KClass <T >): Set <Pair <KClass <* >, KFunction<T>>> {
3437 return clazz.companionObjectInstance?.let { companionObject ->
3538 companionObject::class .functions
3639 .filter { it.annotations.any { annotation -> annotation is KConverter } }
0 commit comments