From 92a6f9f79fbfdc167c0ee7f2586e1701e140370e Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 20:54:10 +0900 Subject: [PATCH 01/15] =?UTF-8?q?MockK=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 a3b1e81..0b14af9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -43,7 +43,7 @@ dependencies { exclude(group = "org.junit.vintage", module = "junit-vintage-engine") } // https://mvnrepository.com/artifact/io.mockk/mockk - testImplementation("io.mockk:mockk:1.9.3") + testImplementation("io.mockk:mockk:1.10.0") // テスト時には無いと困るため、別口でimplementation testImplementation(group = "org.springframework", name = "spring-jdbc", version = "5.2.4.RELEASE") From 89a060f83820ee88cb7ca9b12874aad24c7627d4 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 20:54:25 +0900 Subject: [PATCH 02/15] =?UTF-8?q?Shared=E3=81=AE=E3=82=A2=E3=83=83?= =?UTF-8?q?=E3=83=97=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 0b14af9..06b5f5a 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")) - api("com.github.ProjectMapK:Shared:0.15") + api("com.github.ProjectMapK:Shared:0.16") // 使うのはRowMapperのみなため他はexclude、またバージョンそのものは使う相手に合わせるためcompileOnly compileOnly(group = "org.springframework", name = "spring-jdbc", version = "5.2.4.RELEASE") { exclude(module = "spring-beans") From 959a1f7a3630f78db7d124995336302727180c26 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 20:56:44 +0900 Subject: [PATCH 03/15] =?UTF-8?q?parameterNameConverter=E3=81=AEnullabilit?= =?UTF-8?q?y/=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB=E3=83=88=E3=81=AE?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt b/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt index 8162444..11189a1 100644 --- a/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt +++ b/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt @@ -10,11 +10,11 @@ import org.springframework.jdbc.core.RowMapper class KRowMapper private constructor( private val function: KFunctionForCall ) : RowMapper { - constructor(function: KFunction, parameterNameConverter: (String) -> String = { it }) : this( + constructor(function: KFunction, parameterNameConverter: ((String) -> String)? = null) : this( KFunctionForCall(function, parameterNameConverter) ) - constructor(clazz: KClass, parameterNameConverter: (String) -> String = { it }) : this( + constructor(clazz: KClass, parameterNameConverter: ((String) -> String)? = null) : this( clazz.toKConstructor(parameterNameConverter) ) From 72113bc6a9f8937f01113f0d989a8805cd2ce570 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 20:57:18 +0900 Subject: [PATCH 04/15] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E3=83=83=E3=83=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt b/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt index 11189a1..9d37202 100644 --- a/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt +++ b/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt @@ -7,9 +7,7 @@ import kotlin.reflect.KClass import kotlin.reflect.KFunction import org.springframework.jdbc.core.RowMapper -class KRowMapper private constructor( - private val function: KFunctionForCall -) : RowMapper { +class KRowMapper private constructor(private val function: KFunctionForCall) : RowMapper { constructor(function: KFunction, parameterNameConverter: ((String) -> String)? = null) : this( KFunctionForCall(function, parameterNameConverter) ) From 1d2e480a83126afd51af5c3b745174765087927e Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 20:59:03 +0900 Subject: [PATCH 05/15] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E3=83=83=E3=83=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt index 42c3623..6be7156 100644 --- a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt @@ -24,17 +24,11 @@ internal sealed class ParameterForMap { abstract val clazz: Class<*> abstract fun getObject(rs: ResultSet): Any? - private class Plain( - override val name: String, - override val clazz: Class<*> - ) : ParameterForMap() { + private class Plain(override val name: String, override val clazz: Class<*>) : ParameterForMap() { override fun getObject(rs: ResultSet): Any? = rs.getObject(name, clazz) } - private class Enum( - override val name: String, - override val clazz: Class<*> - ) : ParameterForMap() { + private class Enum(override val name: String, override val clazz: Class<*>) : ParameterForMap() { override fun getObject(rs: ResultSet): Any? = EnumMapper.getEnum(clazz, rs.getString(name)) } From 2ae52d2c2a4f4c1f839a6ad7dabf0675bcbc91d6 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:01:07 +0900 Subject: [PATCH 06/15] =?UTF-8?q?set=E3=82=92=E4=BD=BF=E3=81=86=E7=90=86?= =?UTF-8?q?=E7=94=B1=E3=81=AF=E7=84=A1=E3=81=84=E3=81=9F=E3=82=81list?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt index 6be7156..2fd81f3 100644 --- a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt @@ -111,5 +111,5 @@ private fun deserializerFromCompanionObject(clazz: KClass): Collect functions.map { KFunctionWithInstance(it, instance) as KFunction } - } ?: emptySet() + } ?: emptyList() } From 49c59a77bf941faf303f14855b0ebfda17403b8c Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:05:25 +0900 Subject: [PATCH 07/15] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E4=B8=8A?= =?UTF-8?q?=E7=95=8C=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/deserialization/KColumnDeserialize.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/mapk/deserialization/KColumnDeserialize.kt b/src/main/kotlin/com/mapk/deserialization/KColumnDeserialize.kt index a4d7c72..767850a 100644 --- a/src/main/kotlin/com/mapk/deserialization/KColumnDeserialize.kt +++ b/src/main/kotlin/com/mapk/deserialization/KColumnDeserialize.kt @@ -7,7 +7,7 @@ import kotlin.reflect.KClass @MustBeDocumented annotation class KColumnDeserializeBy(val deserializer: KClass>) -abstract class AbstractKColumnDeserializer(protected val annotation: A) { +abstract class AbstractKColumnDeserializer(protected val annotation: A) { abstract val srcClass: Class abstract fun deserialize(source: S?): D? } From 85d9f5bb3b63c8911ec12ef53d38297f806fce1b Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:16:26 +0900 Subject: [PATCH 08/15] =?UTF-8?q?=E3=82=B8=E3=82=A7=E3=83=8D=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E3=82=92=E5=8F=96=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt index 2fd81f3..064b164 100644 --- a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt @@ -19,10 +19,10 @@ import kotlin.reflect.full.staticFunctions import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.jvmName -internal sealed class ParameterForMap { +internal sealed class ParameterForMap { abstract val name: String - abstract val clazz: Class<*> - abstract fun getObject(rs: ResultSet): Any? + abstract val clazz: Class + abstract fun getObject(rs: ResultSet): D? private class Plain(override val name: String, override val clazz: Class<*>) : ParameterForMap() { override fun getObject(rs: ResultSet): Any? = rs.getObject(name, clazz) From e491ac385e5e19df15c585abe705f5af19a241a1 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:17:10 +0900 Subject: [PATCH 09/15] =?UTF-8?q?=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AF?= =?UTF-8?q?=E6=84=8F=E5=91=B3=E3=81=AB=E6=B7=B7=E4=B9=B1=E3=81=8C=E6=9C=89?= =?UTF-8?q?=E3=82=8A=E3=80=81=E3=81=BE=E3=81=9F=E5=BF=85=E9=A0=88=E3=81=A7?= =?UTF-8?q?=E3=82=82=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=9F=E3=82=81?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt index 064b164..72a8cba 100644 --- a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt @@ -21,7 +21,6 @@ import kotlin.reflect.jvm.jvmName internal sealed class ParameterForMap { abstract val name: String - abstract val clazz: Class abstract fun getObject(rs: ResultSet): D? private class Plain(override val name: String, override val clazz: Class<*>) : ParameterForMap() { From 274dc83bc23fc0a98564e01aea5b87d5a8c5fc0a Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:17:23 +0900 Subject: [PATCH 10/15] =?UTF-8?q?=E3=82=B8=E3=82=A7=E3=83=8D=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt index 72a8cba..3efd264 100644 --- a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt @@ -23,8 +23,8 @@ internal sealed class ParameterForMap { abstract val name: String abstract fun getObject(rs: ResultSet): D? - private class Plain(override val name: String, override val clazz: Class<*>) : ParameterForMap() { - override fun getObject(rs: ResultSet): Any? = rs.getObject(name, clazz) + private class Plain(override val name: String, val requiredClazz: Class) : ParameterForMap() { + override fun getObject(rs: ResultSet): T? = rs.getObject(name, requiredClazz) } private class Enum(override val name: String, override val clazz: Class<*>) : ParameterForMap() { From 7a877a54900f99fa1dd58ea4f2994eec0f4151fe Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:17:59 +0900 Subject: [PATCH 11/15] =?UTF-8?q?=E3=82=B8=E3=82=A7=E3=83=8D=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit class周りの扱いの厳格化のため変数名を改名 --- src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt index 3efd264..471a918 100644 --- a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt @@ -27,8 +27,8 @@ internal sealed class ParameterForMap { override fun getObject(rs: ResultSet): T? = rs.getObject(name, requiredClazz) } - private class Enum(override val name: String, override val clazz: Class<*>) : ParameterForMap() { - override fun getObject(rs: ResultSet): Any? = EnumMapper.getEnum(clazz, rs.getString(name)) + private class Enum(override val name: String, val enumClazz: Class) : ParameterForMap() { + override fun getObject(rs: ResultSet): D? = EnumMapper.getEnum(enumClazz, rs.getString(name)) } private class Deserializer( From 10437b0b49877d9a5ca26a4826dd042db210a150 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:18:26 +0900 Subject: [PATCH 12/15] =?UTF-8?q?=E3=82=B8=E3=82=A7=E3=83=8D=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/mapk/krowmapper/ParameterForMap.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt index 471a918..41fd608 100644 --- a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt @@ -31,17 +31,17 @@ internal sealed class ParameterForMap { override fun getObject(rs: ResultSet): D? = EnumMapper.getEnum(enumClazz, rs.getString(name)) } - private class Deserializer( + private class Deserializer( override val name: String, - override val clazz: Class<*>, - private val deserializer: KFunction<*> - ) : ParameterForMap() { + val srcClazz: Class, + private val deserializer: KFunction + ) : ParameterForMap() { constructor( name: String, - deserializer: AbstractKColumnDeserializer<*, *, *> + deserializer: AbstractKColumnDeserializer<*, S, D> ) : this(name, deserializer.srcClass, deserializer::deserialize) - override fun getObject(rs: ResultSet): Any? = deserializer.call(rs.getObject(name, clazz)) + override fun getObject(rs: ResultSet): D? = deserializer.call(rs.getObject(name, srcClazz)) } companion object { From 0a37f2a72a012771bd1d075f030ed4ea0f656acb Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:18:37 +0900 Subject: [PATCH 13/15] =?UTF-8?q?=E3=82=B8=E3=82=A7=E3=83=8D=E3=83=AA?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt index 41fd608..c21c760 100644 --- a/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/krowmapper/ParameterForMap.kt @@ -45,7 +45,7 @@ internal sealed class ParameterForMap { } companion object { - fun newInstance(param: ValueParameter): ParameterForMap { + fun newInstance(param: ValueParameter): ParameterForMap<*, T> { param.getDeserializer()?.let { return Deserializer(param.name, it) } From cbff7fff6fc2c25cd502288bfad6cefa801e5799 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:18:57 +0900 Subject: [PATCH 14/15] =?UTF-8?q?ParameterForMap=E3=81=AE=E3=82=B8?= =?UTF-8?q?=E3=82=A7=E3=83=8D=E3=83=AA=E3=82=AF=E3=82=B9=E5=8C=96=E3=81=B8?= =?UTF-8?q?=E3=81=AE=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt b/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt index 9d37202..7b8fa48 100644 --- a/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt +++ b/src/main/kotlin/com/mapk/krowmapper/KRowMapper.kt @@ -16,7 +16,8 @@ class KRowMapper private constructor(private val function: KFunctionFor clazz.toKConstructor(parameterNameConverter) ) - private val parameters: List = function.requiredParameters.map { ParameterForMap.newInstance(it) } + private val parameters: List> = + function.requiredParameters.map { ParameterForMap.newInstance(it) } override fun mapRow(rs: ResultSet, rowNum: Int): T { val adaptor = function.getArgumentAdaptor() From 014368561dc3c93b5cf65175f990776e230756a6 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 23 May 2020 21:22:28 +0900 Subject: [PATCH 15/15] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=A2=E3=83=83=E3=83=97?= 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 06b5f5a..b5cc5f6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "com.mapk" -version = "0.13" +version = "0.14" java { sourceCompatibility = JavaVersion.VERSION_1_8