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

Commit 4816193

Browse files
committed
記述を簡略化
1 parent 8005c12 commit 4816193

File tree

1 file changed

+4
-9
lines changed
  • src/main/kotlin/com/wrongwrong/mapk/core

1 file changed

+4
-9
lines changed

src/main/kotlin/com/wrongwrong/mapk/core/KMapper.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.wrongwrong.mapk.annotations.KPropertyAlias
55
import com.wrongwrong.mapk.annotations.KPropertyIgnore
66
import kotlin.reflect.KClass
77
import kotlin.reflect.KFunction
8-
import kotlin.reflect.KParameter
98
import kotlin.reflect.KProperty1
109
import kotlin.reflect.KVisibility
1110
import kotlin.reflect.full.companionObjectInstance
@@ -20,16 +19,12 @@ class KMapper<T : Any>(private val function: KFunction<T>, propertyNameConverter
2019
getTarget(clazz), propertyNameConverter
2120
)
2221

23-
private val parameters: Set<ParameterForMap<*>>
22+
private val parameters: Set<ParameterForMap<*>> = function.parameters
23+
.map { ParameterForMap.newInstance(it, propertyNameConverter) }
24+
.toSet()
2425

2526
init {
26-
val params: List<KParameter> = function.parameters
27-
28-
if (params.isEmpty()) throw IllegalArgumentException("This function is not require arguments.")
29-
30-
parameters = params
31-
.map { ParameterForMap.newInstance(it, propertyNameConverter) }
32-
.toSet()
27+
if (parameters.isEmpty()) throw IllegalArgumentException("This function is not require arguments.")
3328

3429
// private関数に対してもマッピングできなければ何かと不都合があるため、accessibleは書き換える
3530
function.isAccessible = true

0 commit comments

Comments
 (0)