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

Commit d73374c

Browse files
committed
拡張関数の方を使うように修正
1 parent c08467b commit d73374c

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ internal class BoundParameterForMap<S : Any>(val param: KParameter, property: KP
2121
val paramClazz = param.type.classifier as KClass<*>
2222
val propertyClazz = property.returnType.classifier as KClass<*>
2323

24-
val converter = (convertersFromConstructors(paramClazz) +
25-
convertersFromStaticMethods(paramClazz) +
26-
convertersFromCompanionObject(paramClazz))
24+
val converter = paramClazz.getConverters()
2725
.filter { (key, _) -> propertyClazz.isSubclassOf(key) }
2826
.let {
2927
if (1 < it.size) throw IllegalArgumentException("${param.name} has multiple converter. $it")

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ internal class ParameterForMap<T : Any> private constructor(val param: KParamete
1212
clazz.java
1313
}
1414
// リストの長さが小さいと期待されるためこの形で実装しているが、理想的にはmap的なものが使いたい
15-
private val converters: Set<Pair<KClass<*>, KFunction<T>>> = convertersFromConstructors(clazz) +
16-
convertersFromStaticMethods(clazz) +
17-
convertersFromCompanionObject(clazz)
15+
private val converters: Set<Pair<KClass<*>, KFunction<T>>> = clazz.getConverters()
1816

1917
private val convertCache: MutableMap<KClass<*>, (Any) -> Any?> = HashMap()
2018

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ internal class PlainParameterForMap<T : Any> private constructor(val param: KPar
1212
clazz.java
1313
}
1414
// リストの長さが小さいと期待されるためこの形で実装しているが、理想的にはmap的なものが使いたい
15-
private val converters: Set<Pair<KClass<*>, KFunction<T>>> by lazy {
16-
convertersFromConstructors(clazz) + convertersFromStaticMethods(clazz) + convertersFromCompanionObject(clazz)
17-
}
15+
private val converters: Set<Pair<KClass<*>, KFunction<T>>> = clazz.getConverters()
1816

1917
fun <U : Any> mapObject(value: U): Any? {
2018
val valueClazz: KClass<*> = value::class

0 commit comments

Comments
 (0)