Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/kotlin/com/mapk/annotations/KGetterAlias.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ package com.mapk.annotations

@Target(AnnotationTarget.PROPERTY_GETTER)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
annotation class KGetterAlias(val value: String)
6 changes: 3 additions & 3 deletions src/main/kotlin/com/mapk/kmapper/KMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class KMapper<T : Any> private constructor(

val tempBinderArrayList = ArrayList<ArgumentBinder>()

src::class.memberProperties.forEach outer@{ property ->
clazz.memberProperties.forEach outer@{ property ->
// propertyが公開されていない場合は処理を行わない
if (property.visibility != KVisibility.PUBLIC) return@outer

Expand Down Expand Up @@ -130,11 +130,11 @@ class KMapper<T : Any> private constructor(
}

private class ArgumentBinder(private val param: ParameterForMap<*>, private val javaGetter: Method) {
fun bindArgument(value: Any, bucket: ArgumentBucket) {
fun bindArgument(src: Any, bucket: ArgumentBucket) {
// 初期化済みであれば高コストな取得処理は行わない
if (!bucket.containsKey(param.param)) {
// javaGetterを呼び出す方が高速
bucket.putIfAbsent(param.param, javaGetter.invoke(value)?.let { param.mapObject(it) })
bucket.putIfAbsent(param.param, javaGetter.invoke(src)?.let { param.mapObject(it) })
}
}
}