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

Commit 5e1d1bd

Browse files
committed
aliasの取得方法を修正
1 parent cb575c2 commit 5e1d1bd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.mapk.krowmapper
33
import com.mapk.annotations.KParameterAlias
44
import kotlin.reflect.KClass
55
import kotlin.reflect.KParameter
6-
import kotlin.reflect.full.findAnnotation
76

87
class ParameterForMap<D : Any> private constructor(
98
val name: String,
@@ -12,8 +11,17 @@ class ParameterForMap<D : Any> private constructor(
1211
) {
1312
companion object {
1413
fun newInstance(param: KParameter, propertyNameConverter: (String) -> String = { it }): ParameterForMap<*> {
15-
val name: String = (param.findAnnotation<KParameterAlias>()?.value ?: propertyNameConverter(param.name!!))
16-
return ParameterForMap(name, param.index, (param.type.classifier as KClass<*>).java)
14+
var alias: String? = null
15+
16+
param.annotations.forEach {
17+
if (it is KParameterAlias) alias = it.value
18+
}
19+
20+
return ParameterForMap(
21+
alias ?: propertyNameConverter(param.name!!),
22+
param.index,
23+
(param.type.classifier as KClass<*>).java
24+
)
1725
}
1826
}
1927
}

0 commit comments

Comments
 (0)