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

Commit

Permalink
applyで簡略化
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Jul 23, 2020
1 parent e8a6f7c commit ceb75cc
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/main/kotlin/com/mapk/kmapper/BoundKMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ class BoundKMapper<S : Any, D : Any> private constructor(

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

// 必須引数に対応するプロパティがsrcに定義されていない場合エラー
if (temp == null && !it.isOptional) {
throw IllegalArgumentException("Property ${it.name} is not declared in ${src.jvmName}.")
}

temp
}
}

Expand Down

0 comments on commit ceb75cc

Please sign in to comment.