@@ -3,7 +3,6 @@ package com.mapk.kmapper
33import com.mapk.annotations.KGetterAlias
44import com.mapk.annotations.KGetterIgnore
55import com.mapk.core.ArgumentBucket
6- import com.mapk.core.EnumMapper
76import com.mapk.core.KFunctionForCall
87import com.mapk.core.getAliasOrName
98import com.mapk.core.isUseDefaultArgument
@@ -13,7 +12,6 @@ import kotlin.reflect.KClass
1312import kotlin.reflect.KFunction
1413import kotlin.reflect.KParameter
1514import kotlin.reflect.KVisibility
16- import kotlin.reflect.full.isSuperclassOf
1715import kotlin.reflect.full.memberProperties
1816import kotlin.reflect.jvm.javaGetter
1917
@@ -110,22 +108,3 @@ class PlainKMapper<T : Any> private constructor(
110108 return function.call(bucket)
111109 }
112110}
113-
114- private fun <T : Any , R : Any > mapObject (param : PlainParameterForMap <R >, value : T ): Any? {
115- val valueClazz: KClass <* > = value::class
116-
117- // パラメータに対してvalueが代入可能(同じもしくは親クラス)であればそのまま用いる
118- if (param.clazz.isSuperclassOf(valueClazz)) return value
119-
120- val converter: KFunction <* >? = param.getConverter(valueClazz)
121-
122- return when {
123- // converterに一致する組み合わせが有れば設定されていればそれを使う
124- converter != null -> converter.call(value)
125- // 要求された値がenumかつ元が文字列ならenum mapperでマップ
126- param.javaClazz.isEnum && value is String -> EnumMapper .getEnum(param.clazz.java, value)
127- // 要求されているパラメータがStringならtoStringする
128- param.clazz == String ::class -> value.toString()
129- else -> throw IllegalArgumentException (" Can not convert $valueClazz to ${param.clazz} " )
130- }
131- }
0 commit comments