This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +6
-8
lines changed
main/kotlin/com/mapk/krowmapper
test/kotlin/com/mapk/krowmapper Expand file tree Collapse file tree 3 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import org.springframework.jdbc.core.RowMapper
1111
1212class KRowMapper <T : Any > private constructor(
1313 private val function : KFunctionForCall <T >,
14- parameterNameConverter : (String ) -> String = { it }
14+ parameterNameConverter : (String ) -> String
1515) : RowMapper<T> {
1616 constructor (function: KFunction <T >, propertyNameConverter: (String ) -> String = { it }) : this (
1717 KFunctionForCall (function), propertyNameConverter
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ internal class ParameterForMap private constructor(
6262 fun getObject (rs : ResultSet ): Any? = objectGetter(rs)
6363
6464 companion object {
65- fun newInstance (param : KParameter , parameterNameConverter : (String ) -> String = { it } ): ParameterForMap {
65+ fun newInstance (param : KParameter , parameterNameConverter : (String ) -> String ): ParameterForMap {
6666 return ParameterForMap (
6767 param,
6868 parameterNameConverter(param.getAliasOrName()!! ),
@@ -91,18 +91,14 @@ private fun <T : Any> KClass<T>.getDeserializer(): KFunction<T>? {
9191 deserializerFromCompanionObject(this )
9292
9393 return when {
94- deserializers.isEmpty() -> null
95- deserializers.size == 1 -> deserializers.single()
94+ deserializers.size <= 1 -> deserializers.singleOrNull()
9695 else -> throw IllegalArgumentException (" Find multiple deserializer from $jvmName " )
9796 }
9897}
9998
10099private fun <T > Collection<KFunction<T>>.getDeserializerFromFunctions (): Collection <KFunction <T >> {
101100 return filter { it.annotations.any { annotation -> annotation is KColumnDeserializer } }
102- .map { func ->
103- func.isAccessible = true
104- func
105- }
101+ .onEach { it.isAccessible = true }
106102}
107103
108104private fun <T : Any > deserializerFromConstructors (clazz : KClass <T >): Collection <KFunction <T >> {
Original file line number Diff line number Diff line change @@ -6,13 +6,15 @@ import org.h2.jdbcx.JdbcDataSource
66import org.junit.jupiter.api.AfterAll
77import org.junit.jupiter.api.Assertions.assertEquals
88import org.junit.jupiter.api.BeforeAll
9+ import org.junit.jupiter.api.DisplayName
910import org.junit.jupiter.api.Test
1011import org.junit.jupiter.api.TestInstance
1112import org.springframework.jdbc.core.JdbcTemplate
1213import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource
1314import org.springframework.jdbc.core.simple.SimpleJdbcInsert
1415
1516@TestInstance(TestInstance .Lifecycle .PER_CLASS )
17+ @DisplayName(" DBを用いてマッピングを行うテスト" )
1618class UseDBMappingTest {
1719 enum class FooStatus {
1820 active, archive, deleted
You can’t perform that action at this time.
0 commit comments