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

Commit

Permalink
Merge pull request #45 from k163377/update_kotlin
Browse files Browse the repository at this point in the history
Update Kotlin and refactors.
  • Loading branch information
k163377 authored Aug 29, 2020
2 parents 3b0c28e + 655c20d commit ede56f3
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
id("maven")
id("java")
id("org.jetbrains.kotlin.jvm") version "1.3.72"
id("org.jetbrains.kotlin.jvm") version "1.4.0"
// その他補助系
id("org.jlleitschuh.gradle.ktlint") version "9.2.1"
id("org.jlleitschuh.gradle.ktlint") version "9.3.0"
id("jacoco")
id("com.github.ben-manes.versions") version "0.28.0"
}

group = "com.mapk"
version = "0.31"
version = "0.32"

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -33,7 +33,7 @@ repositories {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation(kotlin("reflect"))
api("com.github.ProjectMapK:Shared:0.16")
api("com.github.ProjectMapK:Shared:0.17")

// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter
testImplementation(group = "org.junit.jupiter", name = "junit-jupiter", version = "5.6.2") {
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/com/mapk/kmapper/BoundKMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class BoundKMapper<S : Any, D : Any> private constructor(
val srcPropertiesMap: Map<String, KProperty1<S, *>> = src.memberProperties
.filter {
// アクセス可能かつignoreされてないもののみ抽出
!(it.visibility != KVisibility.PUBLIC) &&
it.getter.annotations.none { annotation -> annotation is KGetterIgnore }
it.visibility == KVisibility.PUBLIC && it.getter.annotations.none { annotation -> annotation is KGetterIgnore }
}.associateBy { it.getter.findAnnotation<KGetterAlias>()?.value ?: it.name }

parameters = function.requiredParameters
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/mapk/kmapper/BoundParameterForMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ internal sealed class BoundParameterForMap<S> {
.let {
if (1 < it.size) throw IllegalArgumentException("${param.name} has multiple converter. $it")

it.singleOrNull()?.second
}?.let {
return UseConverter(param.name, propertyGetter, it)
it.singleOrNull()?.let { (_, converter) ->
return UseConverter(param.name, propertyGetter, converter)
}
}

if (paramClazz.isSubclassOf(propertyClazz)) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/mapk/kmapper/DummyConstructor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

package com.mapk.kmapper

import kotlin.reflect.KFunction
import com.mapk.kmapper.BoundKMapper as Bound
import com.mapk.kmapper.KMapper as Normal
import com.mapk.kmapper.PlainKMapper as Plain
import kotlin.reflect.KFunction

inline fun <reified S : Any, reified D : Any> BoundKMapper(): Bound<S, D> = Bound(D::class, S::class)

Expand Down
4 changes: 2 additions & 2 deletions src/test/kotlin/com/mapk/kmapper/BoundParameterForMapTest.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.mapk.kmapper

import com.mapk.kmapper.testcommons.JvmLanguage
import kotlin.reflect.full.memberProperties
import kotlin.reflect.jvm.javaGetter
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import kotlin.reflect.full.memberProperties
import kotlin.reflect.jvm.javaGetter

@DisplayName("BoundKMapperのパラメータテスト")
class BoundParameterForMapTest {
Expand Down
9 changes: 4 additions & 5 deletions src/test/kotlin/com/mapk/kmapper/ConversionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ package com.mapk.kmapper

import com.mapk.conversion.AbstractKConverter
import com.mapk.conversion.KConvertBy
import java.lang.IllegalArgumentException
import java.math.BigDecimal
import java.math.BigInteger
import kotlin.reflect.KClass
import kotlin.reflect.jvm.jvmName
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.DisplayName
Expand All @@ -16,6 +11,10 @@ import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.EnumSource
import org.junit.jupiter.params.provider.ValueSource
import java.math.BigDecimal
import java.math.BigInteger
import kotlin.reflect.KClass
import kotlin.reflect.jvm.jvmName

@DisplayName("KConvertアノテーションによる変換のテスト")
class ConversionTest {
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/com/mapk/kmapper/ConverterKMapperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private data class ConstructorConverter @KConverter constructor(val arg: Number)
private data class CompanionConverterDst(val argument: CompanionConverter)
// NOTE: privateクラスのcompanion objectにアクセスする方法を見つけられなかった
class CompanionConverter private constructor(val arg: String) {
private companion object {
companion object {
@KConverter
private fun converter(arg: String): CompanionConverter {
return CompanionConverter(arg)
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/com/mapk/kmapper/KParameterFlattenTest.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.mapk.kmapper

import com.mapk.annotations.KParameterFlatten
import java.time.LocalDateTime
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import java.time.LocalDateTime

@DisplayName("KParameterFlattenテスト")
class KParameterFlattenTest {
Expand Down
8 changes: 4 additions & 4 deletions src/test/kotlin/com/mapk/kmapper/SimpleKMapperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
package com.mapk.kmapper

import com.mapk.annotations.KConstructor
import java.math.BigInteger
import java.util.stream.Stream
import kotlin.reflect.full.isSubclassOf
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Nested
Expand All @@ -15,6 +12,9 @@ import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.Arguments
import org.junit.jupiter.params.provider.Arguments.arguments
import org.junit.jupiter.params.provider.MethodSource
import java.math.BigInteger
import java.util.stream.Stream
import kotlin.reflect.full.isSubclassOf

open class SimpleDst(
val arg1: Int,
Expand Down Expand Up @@ -48,7 +48,7 @@ class SimpleDstExt(
arg2: String?,
arg3: Number
) : SimpleDst(arg1, arg2, arg3) {
private companion object {
companion object {
@KConstructor
fun factory(arg1: Int, arg2: String?, arg3: Number): SimpleDstExt {
return SimpleDstExt(arg1, arg2, arg3)
Expand Down

0 comments on commit ede56f3

Please sign in to comment.