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

Commit ceb75cc

Browse files
committed
applyで簡略化
1 parent e8a6f7c commit ceb75cc

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@ class BoundKMapper<S : Any, D : Any> private constructor(
3838

3939
parameters = function.requiredParameters
4040
.mapNotNull {
41-
val temp = srcPropertiesMap[it.name]?.let { property ->
41+
srcPropertiesMap[it.name]?.let { property ->
4242
BoundParameterForMap.newInstance(it, property, parameterNameConverter)
43+
}.apply {
44+
// 必須引数に対応するプロパティがsrcに定義されていない場合エラー
45+
if (this == null && !it.isOptional)
46+
throw IllegalArgumentException("Property ${it.name} is not declared in ${src.jvmName}.")
4347
}
44-
45-
// 必須引数に対応するプロパティがsrcに定義されていない場合エラー
46-
if (temp == null && !it.isOptional) {
47-
throw IllegalArgumentException("Property ${it.name} is not declared in ${src.jvmName}.")
48-
}
49-
50-
temp
5148
}
5249
}
5350

0 commit comments

Comments
 (0)