From 912f35e66bd26ee5f29af19e70505307d72a28fb Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Tue, 17 Mar 2020 08:24:59 +0900 Subject: [PATCH 1/4] =?UTF-8?q?shared=E3=81=AE=E3=82=A2=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同時に依存の伝搬ができていなかった問題を修正 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index a26b7af..9430083 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,7 +30,7 @@ repositories { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") implementation(kotlin("reflect")) - implementation("com.github.ProjectMapK:Shared:0.6") + api("com.github.ProjectMapK:Shared:0.7") // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter testImplementation(group = "org.junit.jupiter", name = "junit-jupiter", version = "5.6.0") { From 8cf821f4a27ab73a0dcaf7fc8b420aa2c974c671 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Tue, 17 Mar 2020 08:25:14 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9430083..590f9f5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "com.mapk" -version = "0.15" +version = "0.16" java { sourceCompatibility = JavaVersion.VERSION_1_8 From 4d947f17aee4a65cfff3e7083c5385295a28776d Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Tue, 17 Mar 2020 08:30:28 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=88=E5=80=A4=E3=82=92=E4=BD=BF=E3=81=86=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E5=BC=95=E6=95=B0=E3=82=92=E7=84=A1=E8=A6=96=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/kmapper/KMapper.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/mapk/kmapper/KMapper.kt b/src/main/kotlin/com/mapk/kmapper/KMapper.kt index bf03103..e68ddc0 100644 --- a/src/main/kotlin/com/mapk/kmapper/KMapper.kt +++ b/src/main/kotlin/com/mapk/kmapper/KMapper.kt @@ -6,6 +6,7 @@ import com.mapk.core.ArgumentBucket import com.mapk.core.EnumMapper import com.mapk.core.KFunctionForCall import com.mapk.core.getAliasOrName +import com.mapk.core.isUseDefaultArgument import com.mapk.core.toKConstructor import java.lang.reflect.Method import kotlin.reflect.KClass @@ -29,7 +30,7 @@ class KMapper private constructor( ) private val parameterMap: Map> = function.parameters - .filter { it.kind != KParameter.Kind.INSTANCE } + .filter { it.kind != KParameter.Kind.INSTANCE && !it.isUseDefaultArgument() } .associate { (propertyNameConverter(it.getAliasOrName()!!)) to ParameterForMap.newInstance(it) } private fun bindArguments(argumentBucket: ArgumentBucket, src: Any) { From 438e796b5cc1b7e5a981cc6ba84c6ffba197c229 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Tue, 17 Mar 2020 08:36:48 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=88=E5=80=A4=E3=82=92=E7=94=A8=E3=81=84=E3=81=9F=E3=83=9E?= =?UTF-8?q?=E3=83=83=E3=83=94=E3=83=B3=E3=82=B0=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mapk/kmapper/DefaultArgumentTest.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/kotlin/com/mapk/kmapper/DefaultArgumentTest.kt diff --git a/src/test/kotlin/com/mapk/kmapper/DefaultArgumentTest.kt b/src/test/kotlin/com/mapk/kmapper/DefaultArgumentTest.kt new file mode 100644 index 0000000..c950702 --- /dev/null +++ b/src/test/kotlin/com/mapk/kmapper/DefaultArgumentTest.kt @@ -0,0 +1,20 @@ +package com.mapk.kmapper + +import com.mapk.annotations.KUseDefaultArgument +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test + +@DisplayName("デフォルト引数を指定するテスト") +class DefaultArgumentTest { + data class Dst(val fooArgument: Int, @param:KUseDefaultArgument val barArgument: String = "default") + data class Src(val fooArgument: Int, val barArgument: String) + + @Test + fun test() { + val src = Src(1, "src") + + val result = KMapper(::Dst).map(src) + assertEquals(Dst(1, "default"), result) + } +}