From c55aba47a3cfe87215fe9486e042c1461d0a6cdf Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 29 Feb 2020 21:25:10 +0900 Subject: [PATCH 01/13] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E5=90=8D=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/KMapper.iml | 2 ++ .idea/kotlinc.xml | 6 ++++++ settings.gradle.kts | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .idea/KMapper.iml create mode 100644 .idea/kotlinc.xml diff --git a/.idea/KMapper.iml b/.idea/KMapper.iml new file mode 100644 index 0000000..78b2cc5 --- /dev/null +++ b/.idea/KMapper.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..0dd4b35 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 0697be7..25da0cf 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1 @@ -rootProject.name = "MapK" +rootProject.name = "KMapper" From 2be15839d2e38afef87d36b6d77a796694b45f6d Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 29 Feb 2020 21:25:34 +0900 Subject: [PATCH 02/13] =?UTF-8?q?group=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ついでにバージョンを修正 --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index bce42cf..2873dfd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,8 +5,8 @@ plugins { id("org.jlleitschuh.gradle.ktlint") version "9.2.1" } -group = "com.wrongwrong" -version = "0.1" +group = "com.mapk" +version = "0.10" java { sourceCompatibility = JavaVersion.VERSION_1_8 From 7648a78d35457947d59806a47720eb7aca694e46 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 29 Feb 2020 21:27:44 +0900 Subject: [PATCH 03/13] =?UTF-8?q?=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E5=90=8D=E3=82=92=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapk/core/EnumMapper.java | 2 +- .../mapk/annotations/KConstructor.kt | 2 +- .../mapk/annotations/KConverter.kt | 2 +- .../mapk/annotations/KGetterAlias.kt | 2 +- .../mapk/annotations/KPropertyAlias.kt | 2 +- .../mapk/annotations/KPropertyIgnore.kt | 2 +- .../mapk/core/ArgumentBucket.kt | 9 +++-- .../mapk/core/KFunctionForCall.kt | 2 +- .../mapk/core/KFunctionWithInstance.kt | 2 +- .../com/{wrongwrong => }/mapk/core/KMapper.kt | 35 ++++++++++++++----- .../mapk/core/ParameterForMap.kt | 13 ++++--- .../java/mapk/core/StaticMethodConverter.java | 2 +- .../kotlin/mapk/core/ConverterKMapperTest.kt | 4 +-- src/test/kotlin/mapk/core/EnumMappingTest.kt | 2 +- src/test/kotlin/mapk/core/GetTargetTest.kt | 6 ++-- src/test/kotlin/mapk/core/ParamAliasTest.kt | 6 ++-- .../mapk/core/PropertyNameConverterTest.kt | 9 +++-- .../kotlin/mapk/core/SimpleKMapperTest.kt | 4 +-- .../kotlin/mapk/core/StringMappingTest.kt | 2 +- 19 files changed, 70 insertions(+), 38 deletions(-) rename src/main/java/com/{wrongwrong => }/mapk/core/EnumMapper.java (94%) rename src/main/kotlin/com/{wrongwrong => }/mapk/annotations/KConstructor.kt (79%) rename src/main/kotlin/com/{wrongwrong => }/mapk/annotations/KConverter.kt (79%) rename src/main/kotlin/com/{wrongwrong => }/mapk/annotations/KGetterAlias.kt (75%) rename src/main/kotlin/com/{wrongwrong => }/mapk/annotations/KPropertyAlias.kt (77%) rename src/main/kotlin/com/{wrongwrong => }/mapk/annotations/KPropertyIgnore.kt (76%) rename src/main/kotlin/com/{wrongwrong => }/mapk/core/ArgumentBucket.kt (83%) rename src/main/kotlin/com/{wrongwrong => }/mapk/core/KFunctionForCall.kt (97%) rename src/main/kotlin/com/{wrongwrong => }/mapk/core/KFunctionWithInstance.kt (96%) rename src/main/kotlin/com/{wrongwrong => }/mapk/core/KMapper.kt (89%) rename src/main/kotlin/com/{wrongwrong => }/mapk/core/ParameterForMap.kt (89%) diff --git a/src/main/java/com/wrongwrong/mapk/core/EnumMapper.java b/src/main/java/com/mapk/core/EnumMapper.java similarity index 94% rename from src/main/java/com/wrongwrong/mapk/core/EnumMapper.java rename to src/main/java/com/mapk/core/EnumMapper.java index 11f8a18..2d73742 100644 --- a/src/main/java/com/wrongwrong/mapk/core/EnumMapper.java +++ b/src/main/java/com/mapk/core/EnumMapper.java @@ -1,4 +1,4 @@ -package com.wrongwrong.mapk.core; +package com.mapk.core; class EnumMapper { /** diff --git a/src/main/kotlin/com/wrongwrong/mapk/annotations/KConstructor.kt b/src/main/kotlin/com/mapk/annotations/KConstructor.kt similarity index 79% rename from src/main/kotlin/com/wrongwrong/mapk/annotations/KConstructor.kt rename to src/main/kotlin/com/mapk/annotations/KConstructor.kt index d73c2c6..6ea3720 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/annotations/KConstructor.kt +++ b/src/main/kotlin/com/mapk/annotations/KConstructor.kt @@ -1,4 +1,4 @@ -package com.wrongwrong.mapk.annotations +package com.mapk.annotations @Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION) @Retention(AnnotationRetention.RUNTIME) diff --git a/src/main/kotlin/com/wrongwrong/mapk/annotations/KConverter.kt b/src/main/kotlin/com/mapk/annotations/KConverter.kt similarity index 79% rename from src/main/kotlin/com/wrongwrong/mapk/annotations/KConverter.kt rename to src/main/kotlin/com/mapk/annotations/KConverter.kt index b2fb6e6..35034f7 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/annotations/KConverter.kt +++ b/src/main/kotlin/com/mapk/annotations/KConverter.kt @@ -1,4 +1,4 @@ -package com.wrongwrong.mapk.annotations +package com.mapk.annotations @Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION) @Retention(AnnotationRetention.RUNTIME) diff --git a/src/main/kotlin/com/wrongwrong/mapk/annotations/KGetterAlias.kt b/src/main/kotlin/com/mapk/annotations/KGetterAlias.kt similarity index 75% rename from src/main/kotlin/com/wrongwrong/mapk/annotations/KGetterAlias.kt rename to src/main/kotlin/com/mapk/annotations/KGetterAlias.kt index 6bf6815..8195905 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/annotations/KGetterAlias.kt +++ b/src/main/kotlin/com/mapk/annotations/KGetterAlias.kt @@ -1,4 +1,4 @@ -package com.wrongwrong.mapk.annotations +package com.mapk.annotations @Target(AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.RUNTIME) diff --git a/src/main/kotlin/com/wrongwrong/mapk/annotations/KPropertyAlias.kt b/src/main/kotlin/com/mapk/annotations/KPropertyAlias.kt similarity index 77% rename from src/main/kotlin/com/wrongwrong/mapk/annotations/KPropertyAlias.kt rename to src/main/kotlin/com/mapk/annotations/KPropertyAlias.kt index eab10fa..62105be 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/annotations/KPropertyAlias.kt +++ b/src/main/kotlin/com/mapk/annotations/KPropertyAlias.kt @@ -1,4 +1,4 @@ -package com.wrongwrong.mapk.annotations +package com.mapk.annotations @Target(AnnotationTarget.VALUE_PARAMETER) @Retention(AnnotationRetention.RUNTIME) diff --git a/src/main/kotlin/com/wrongwrong/mapk/annotations/KPropertyIgnore.kt b/src/main/kotlin/com/mapk/annotations/KPropertyIgnore.kt similarity index 76% rename from src/main/kotlin/com/wrongwrong/mapk/annotations/KPropertyIgnore.kt rename to src/main/kotlin/com/mapk/annotations/KPropertyIgnore.kt index 63e069f..70db6ee 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/annotations/KPropertyIgnore.kt +++ b/src/main/kotlin/com/mapk/annotations/KPropertyIgnore.kt @@ -1,4 +1,4 @@ -package com.wrongwrong.mapk.annotations +package com.mapk.annotations @Target(AnnotationTarget.PROPERTY) @Retention(AnnotationRetention.RUNTIME) diff --git a/src/main/kotlin/com/wrongwrong/mapk/core/ArgumentBucket.kt b/src/main/kotlin/com/mapk/core/ArgumentBucket.kt similarity index 83% rename from src/main/kotlin/com/wrongwrong/mapk/core/ArgumentBucket.kt rename to src/main/kotlin/com/mapk/core/ArgumentBucket.kt index 0a3b291..3b09578 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/core/ArgumentBucket.kt +++ b/src/main/kotlin/com/mapk/core/ArgumentBucket.kt @@ -1,4 +1,4 @@ -package com.wrongwrong.mapk.core +package com.mapk.core class ArgumentBucket( val bucket: Array, @@ -21,6 +21,11 @@ class ArgumentBucket( } public override fun clone(): ArgumentBucket { - return ArgumentBucket(bucket.copyOf(), initializeStatus, initializeMask, completionValue) + return ArgumentBucket( + bucket.copyOf(), + initializeStatus, + initializeMask, + completionValue + ) } } diff --git a/src/main/kotlin/com/wrongwrong/mapk/core/KFunctionForCall.kt b/src/main/kotlin/com/mapk/core/KFunctionForCall.kt similarity index 97% rename from src/main/kotlin/com/wrongwrong/mapk/core/KFunctionForCall.kt rename to src/main/kotlin/com/mapk/core/KFunctionForCall.kt index 0802090..566f79e 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/core/KFunctionForCall.kt +++ b/src/main/kotlin/com/mapk/core/KFunctionForCall.kt @@ -1,4 +1,4 @@ -package com.wrongwrong.mapk.core +package com.mapk.core import kotlin.reflect.KFunction import kotlin.reflect.KParameter diff --git a/src/main/kotlin/com/wrongwrong/mapk/core/KFunctionWithInstance.kt b/src/main/kotlin/com/mapk/core/KFunctionWithInstance.kt similarity index 96% rename from src/main/kotlin/com/wrongwrong/mapk/core/KFunctionWithInstance.kt rename to src/main/kotlin/com/mapk/core/KFunctionWithInstance.kt index d3fa059..1431a7f 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/core/KFunctionWithInstance.kt +++ b/src/main/kotlin/com/mapk/core/KFunctionWithInstance.kt @@ -1,4 +1,4 @@ -package com.wrongwrong.mapk.core +package com.mapk.core import kotlin.reflect.KFunction import kotlin.reflect.KParameter diff --git a/src/main/kotlin/com/wrongwrong/mapk/core/KMapper.kt b/src/main/kotlin/com/mapk/core/KMapper.kt similarity index 89% rename from src/main/kotlin/com/wrongwrong/mapk/core/KMapper.kt rename to src/main/kotlin/com/mapk/core/KMapper.kt index c67d38e..613f9d4 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/core/KMapper.kt +++ b/src/main/kotlin/com/mapk/core/KMapper.kt @@ -1,9 +1,9 @@ -package com.wrongwrong.mapk.core +package com.mapk.core -import com.wrongwrong.mapk.annotations.KConstructor -import com.wrongwrong.mapk.annotations.KGetterAlias -import com.wrongwrong.mapk.annotations.KPropertyAlias -import com.wrongwrong.mapk.annotations.KPropertyIgnore +import com.mapk.annotations.KConstructor +import com.mapk.annotations.KGetterAlias +import com.mapk.annotations.KPropertyAlias +import com.mapk.annotations.KPropertyIgnore import java.lang.reflect.Method import kotlin.reflect.KClass import kotlin.reflect.KFunction @@ -58,7 +58,12 @@ class KMapper private constructor( parameterMap[property.findAnnotation()?.value ?: property.name]?.let { // javaGetterを呼び出す方が高速 javaGetter.isAccessible = true - argumentBucket.setArgument(javaGetter.invoke(src)?.let { value -> mapObject(it, value) }, it.index) + argumentBucket.setArgument(javaGetter.invoke(src)?.let { value -> + mapObject( + it, + value + ) + }, it.index) // 終了判定 if (argumentBucket.isInitialized) return } @@ -79,7 +84,12 @@ class KMapper private constructor( private fun bindArguments(argumentBucket: ArgumentBucket, srcPair: Pair<*, *>) { parameterMap[srcPair.first.toString()]?.let { - argumentBucket.setArgument(srcPair.second?.let { value -> mapObject(it, value) }, it.index) + argumentBucket.setArgument(srcPair.second?.let { value -> + mapObject( + it, + value + ) + }, it.index) } } @@ -133,7 +143,11 @@ internal fun getTarget(clazz: KClass): KFunctionForCall { clazz.companionObjectInstance?.let { companionObject -> companionObject::class.functions .filter { it.annotations.any { annotation -> annotation is KConstructor } } - .map { KFunctionForCall(it, companionObject) as KFunctionForCall } + .map { KFunctionForCall( + it, + companionObject + ) as KFunctionForCall + } } ?: emptyList() val constructors: List> = factoryConstructor + clazz.constructors @@ -159,7 +173,10 @@ private fun mapObject(param: ParameterForMap, value: T): A // creatorに一致する組み合わせが有れば設定されていればそれを使う creator != null -> creator.call(value) // 要求された値がenumかつ元が文字列ならenum mapperでマップ - param.javaClazz.isEnum && value is String -> EnumMapper.getEnum(param.clazz.java, value) + param.javaClazz.isEnum && value is String -> EnumMapper.getEnum( + param.clazz.java, + value + ) // 要求されているパラメータがStringならtoStringする param.clazz == String::class -> value.toString() else -> throw IllegalArgumentException("Can not convert $valueClazz to ${param.clazz}") diff --git a/src/main/kotlin/com/wrongwrong/mapk/core/ParameterForMap.kt b/src/main/kotlin/com/mapk/core/ParameterForMap.kt similarity index 89% rename from src/main/kotlin/com/wrongwrong/mapk/core/ParameterForMap.kt rename to src/main/kotlin/com/mapk/core/ParameterForMap.kt index 4f3d0b3..acdf1a9 100644 --- a/src/main/kotlin/com/wrongwrong/mapk/core/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/core/ParameterForMap.kt @@ -1,6 +1,6 @@ -package com.wrongwrong.mapk.core +package com.mapk.core -import com.wrongwrong.mapk.annotations.KConverter +import com.mapk.annotations.KConverter import kotlin.reflect.KClass import kotlin.reflect.KFunction import kotlin.reflect.KParameter @@ -16,7 +16,9 @@ internal class ParameterForMap private constructor(val index: Int, val } // リストの長さが小さいと期待されるためこの形で実装しているが、理想的にはmap的なものが使いたい private val creators: Set, KFunction>> by lazy { - creatorsFromConstructors(clazz) + creatorsFromStaticMethods(clazz) + creatorsFromCompanionObject(clazz) + creatorsFromConstructors(clazz) + creatorsFromStaticMethods( + clazz + ) + creatorsFromCompanionObject(clazz) } // 引数の型がcreatorに対して入力可能ならcreatorを返す @@ -56,7 +58,10 @@ private fun creatorsFromCompanionObject(clazz: KClass): Set annotation is KConverter } } .map { function -> - val func: KFunction = KFunctionWithInstance(function, companionObject) as KFunction + val func: KFunction = KFunctionWithInstance( + function, + companionObject + ) as KFunction (func.parameters.single().type.classifier as KClass<*>) to func }.toSet() diff --git a/src/test/java/mapk/core/StaticMethodConverter.java b/src/test/java/mapk/core/StaticMethodConverter.java index 56fa412..c0b3c26 100644 --- a/src/test/java/mapk/core/StaticMethodConverter.java +++ b/src/test/java/mapk/core/StaticMethodConverter.java @@ -1,6 +1,6 @@ package mapk.core; -import com.wrongwrong.mapk.annotations.KConverter; +import com.mapk.annotations.KConverter; import java.util.Arrays; diff --git a/src/test/kotlin/mapk/core/ConverterKMapperTest.kt b/src/test/kotlin/mapk/core/ConverterKMapperTest.kt index fe92e91..5b45ae3 100644 --- a/src/test/kotlin/mapk/core/ConverterKMapperTest.kt +++ b/src/test/kotlin/mapk/core/ConverterKMapperTest.kt @@ -2,8 +2,8 @@ package mapk.core -import com.wrongwrong.mapk.annotations.KConverter -import com.wrongwrong.mapk.core.KMapper +import com.mapk.annotations.KConverter +import com.mapk.core.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.DisplayName diff --git a/src/test/kotlin/mapk/core/EnumMappingTest.kt b/src/test/kotlin/mapk/core/EnumMappingTest.kt index 8edd826..c35d51f 100644 --- a/src/test/kotlin/mapk/core/EnumMappingTest.kt +++ b/src/test/kotlin/mapk/core/EnumMappingTest.kt @@ -2,7 +2,7 @@ package mapk.core -import com.wrongwrong.mapk.core.KMapper +import com.mapk.core.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.params.ParameterizedTest diff --git a/src/test/kotlin/mapk/core/GetTargetTest.kt b/src/test/kotlin/mapk/core/GetTargetTest.kt index 54057a0..0c3feff 100644 --- a/src/test/kotlin/mapk/core/GetTargetTest.kt +++ b/src/test/kotlin/mapk/core/GetTargetTest.kt @@ -2,9 +2,9 @@ package mapk.core -import com.wrongwrong.mapk.annotations.KConstructor -import com.wrongwrong.mapk.core.KFunctionForCall -import com.wrongwrong.mapk.core.getTarget +import com.mapk.annotations.KConstructor +import com.mapk.core.KFunctionForCall +import com.mapk.core.getTarget import kotlin.reflect.KFunction import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor diff --git a/src/test/kotlin/mapk/core/ParamAliasTest.kt b/src/test/kotlin/mapk/core/ParamAliasTest.kt index 3929b90..31f6a38 100644 --- a/src/test/kotlin/mapk/core/ParamAliasTest.kt +++ b/src/test/kotlin/mapk/core/ParamAliasTest.kt @@ -1,8 +1,8 @@ package mapk.core -import com.wrongwrong.mapk.annotations.KGetterAlias -import com.wrongwrong.mapk.annotations.KPropertyAlias -import com.wrongwrong.mapk.core.KMapper +import com.mapk.annotations.KGetterAlias +import com.mapk.annotations.KPropertyAlias +import com.mapk.core.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test diff --git a/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt b/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt index 9f48670..3621835 100644 --- a/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt +++ b/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt @@ -1,7 +1,7 @@ package mapk.core import com.google.common.base.CaseFormat -import com.wrongwrong.mapk.core.KMapper +import com.mapk.core.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test @@ -16,7 +16,12 @@ class PropertyNameConverterTest { val expected = "snakeCase" val src = mapOf("camel_case" to expected) - val mapper = KMapper(CamelCaseDst::class) { CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, it) } + val mapper = KMapper(CamelCaseDst::class) { + CaseFormat.LOWER_CAMEL.to( + CaseFormat.LOWER_UNDERSCORE, + it + ) + } val result = mapper.map(src) assertEquals(expected, result.camelCase) diff --git a/src/test/kotlin/mapk/core/SimpleKMapperTest.kt b/src/test/kotlin/mapk/core/SimpleKMapperTest.kt index d90be59..4720091 100644 --- a/src/test/kotlin/mapk/core/SimpleKMapperTest.kt +++ b/src/test/kotlin/mapk/core/SimpleKMapperTest.kt @@ -2,8 +2,8 @@ package mapk.core -import com.wrongwrong.mapk.annotations.KConstructor -import com.wrongwrong.mapk.core.KMapper +import com.mapk.annotations.KConstructor +import com.mapk.core.KMapper import java.math.BigInteger import kotlin.reflect.full.isSubclassOf import org.junit.jupiter.api.Assertions.assertEquals diff --git a/src/test/kotlin/mapk/core/StringMappingTest.kt b/src/test/kotlin/mapk/core/StringMappingTest.kt index cb3b2a7..05ad3a6 100644 --- a/src/test/kotlin/mapk/core/StringMappingTest.kt +++ b/src/test/kotlin/mapk/core/StringMappingTest.kt @@ -1,6 +1,6 @@ package mapk.core -import com.wrongwrong.mapk.core.KMapper +import com.mapk.core.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test From 40972178f0b1e23ceca01af5ce629a6803dd7e4b Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 29 Feb 2020 21:46:11 +0900 Subject: [PATCH 04/13] =?UTF-8?q?=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E5=88=86=E3=81=91=E3=81=AB=E4=BC=B4=E3=81=84public?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/mapk/core/EnumMapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/mapk/core/EnumMapper.java b/src/main/java/com/mapk/core/EnumMapper.java index 2d73742..d5074ad 100644 --- a/src/main/java/com/mapk/core/EnumMapper.java +++ b/src/main/java/com/mapk/core/EnumMapper.java @@ -1,6 +1,6 @@ package com.mapk.core; -class EnumMapper { +public class EnumMapper { /** * Kotlinの型推論バグでクラスからvalueOfが使えないため、ここだけJavaで書いている(型引数もT extends Enumでは書けなかった) * @param clazz Class of Enum @@ -9,7 +9,7 @@ class EnumMapper { * @return Enum.valueOf */ @SuppressWarnings({"unchecked", "rawtypes"}) - static T getEnum(Class clazz, String value) { + public static T getEnum(Class clazz, String value) { if (value == null || value.isEmpty()) { return null; } From b1c12db790c50d34f528d1e713eef36c28b444fb Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 29 Feb 2020 21:48:20 +0900 Subject: [PATCH 05/13] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E5=88=86=E5=89=B2=E3=81=AB=E4=BC=B4=E3=81=86?= =?UTF-8?q?=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/mapk/{core => kmapper}/KMapper.kt | 5 ++++- .../kotlin/com/mapk/{core => kmapper}/ParameterForMap.kt | 3 ++- src/test/kotlin/mapk/core/ConverterKMapperTest.kt | 2 +- src/test/kotlin/mapk/core/EnumMappingTest.kt | 2 +- src/test/kotlin/mapk/core/GetTargetTest.kt | 2 +- src/test/kotlin/mapk/core/ParamAliasTest.kt | 2 +- src/test/kotlin/mapk/core/PropertyNameConverterTest.kt | 2 +- src/test/kotlin/mapk/core/SimpleKMapperTest.kt | 2 +- src/test/kotlin/mapk/core/StringMappingTest.kt | 2 +- 9 files changed, 13 insertions(+), 9 deletions(-) rename src/main/kotlin/com/mapk/{core => kmapper}/KMapper.kt (98%) rename src/main/kotlin/com/mapk/{core => kmapper}/ParameterForMap.kt (97%) diff --git a/src/main/kotlin/com/mapk/core/KMapper.kt b/src/main/kotlin/com/mapk/kmapper/KMapper.kt similarity index 98% rename from src/main/kotlin/com/mapk/core/KMapper.kt rename to src/main/kotlin/com/mapk/kmapper/KMapper.kt index 613f9d4..d9a1a6c 100644 --- a/src/main/kotlin/com/mapk/core/KMapper.kt +++ b/src/main/kotlin/com/mapk/kmapper/KMapper.kt @@ -1,9 +1,12 @@ -package com.mapk.core +package com.mapk.kmapper import com.mapk.annotations.KConstructor import com.mapk.annotations.KGetterAlias import com.mapk.annotations.KPropertyAlias import com.mapk.annotations.KPropertyIgnore +import com.mapk.core.ArgumentBucket +import com.mapk.core.EnumMapper +import com.mapk.core.KFunctionForCall import java.lang.reflect.Method import kotlin.reflect.KClass import kotlin.reflect.KFunction diff --git a/src/main/kotlin/com/mapk/core/ParameterForMap.kt b/src/main/kotlin/com/mapk/kmapper/ParameterForMap.kt similarity index 97% rename from src/main/kotlin/com/mapk/core/ParameterForMap.kt rename to src/main/kotlin/com/mapk/kmapper/ParameterForMap.kt index acdf1a9..b355d8d 100644 --- a/src/main/kotlin/com/mapk/core/ParameterForMap.kt +++ b/src/main/kotlin/com/mapk/kmapper/ParameterForMap.kt @@ -1,6 +1,7 @@ -package com.mapk.core +package com.mapk.kmapper import com.mapk.annotations.KConverter +import com.mapk.core.KFunctionWithInstance import kotlin.reflect.KClass import kotlin.reflect.KFunction import kotlin.reflect.KParameter diff --git a/src/test/kotlin/mapk/core/ConverterKMapperTest.kt b/src/test/kotlin/mapk/core/ConverterKMapperTest.kt index 5b45ae3..0cd72da 100644 --- a/src/test/kotlin/mapk/core/ConverterKMapperTest.kt +++ b/src/test/kotlin/mapk/core/ConverterKMapperTest.kt @@ -3,7 +3,7 @@ package mapk.core import com.mapk.annotations.KConverter -import com.mapk.core.KMapper +import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.DisplayName diff --git a/src/test/kotlin/mapk/core/EnumMappingTest.kt b/src/test/kotlin/mapk/core/EnumMappingTest.kt index c35d51f..ddff018 100644 --- a/src/test/kotlin/mapk/core/EnumMappingTest.kt +++ b/src/test/kotlin/mapk/core/EnumMappingTest.kt @@ -2,7 +2,7 @@ package mapk.core -import com.mapk.core.KMapper +import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.params.ParameterizedTest diff --git a/src/test/kotlin/mapk/core/GetTargetTest.kt b/src/test/kotlin/mapk/core/GetTargetTest.kt index 0c3feff..aa50a03 100644 --- a/src/test/kotlin/mapk/core/GetTargetTest.kt +++ b/src/test/kotlin/mapk/core/GetTargetTest.kt @@ -4,7 +4,7 @@ package mapk.core import com.mapk.annotations.KConstructor import com.mapk.core.KFunctionForCall -import com.mapk.core.getTarget +import com.mapk.kmapper.getTarget import kotlin.reflect.KFunction import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor diff --git a/src/test/kotlin/mapk/core/ParamAliasTest.kt b/src/test/kotlin/mapk/core/ParamAliasTest.kt index 31f6a38..e9035a1 100644 --- a/src/test/kotlin/mapk/core/ParamAliasTest.kt +++ b/src/test/kotlin/mapk/core/ParamAliasTest.kt @@ -2,7 +2,7 @@ package mapk.core import com.mapk.annotations.KGetterAlias import com.mapk.annotations.KPropertyAlias -import com.mapk.core.KMapper +import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test diff --git a/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt b/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt index 3621835..e2be121 100644 --- a/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt +++ b/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt @@ -1,7 +1,7 @@ package mapk.core import com.google.common.base.CaseFormat -import com.mapk.core.KMapper +import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test diff --git a/src/test/kotlin/mapk/core/SimpleKMapperTest.kt b/src/test/kotlin/mapk/core/SimpleKMapperTest.kt index 4720091..23d5af2 100644 --- a/src/test/kotlin/mapk/core/SimpleKMapperTest.kt +++ b/src/test/kotlin/mapk/core/SimpleKMapperTest.kt @@ -3,7 +3,7 @@ package mapk.core import com.mapk.annotations.KConstructor -import com.mapk.core.KMapper +import com.mapk.kmapper.KMapper import java.math.BigInteger import kotlin.reflect.full.isSubclassOf import org.junit.jupiter.api.Assertions.assertEquals diff --git a/src/test/kotlin/mapk/core/StringMappingTest.kt b/src/test/kotlin/mapk/core/StringMappingTest.kt index 05ad3a6..7c1776a 100644 --- a/src/test/kotlin/mapk/core/StringMappingTest.kt +++ b/src/test/kotlin/mapk/core/StringMappingTest.kt @@ -1,6 +1,6 @@ package mapk.core -import com.mapk.core.KMapper +import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test From e63539a5101bec05cfaf4808598a7d375b3ca47d Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 29 Feb 2020 21:57:24 +0900 Subject: [PATCH 06/13] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{mapk/core => com/mapk/kmapper}/StaticMethodConverter.java | 2 +- .../{mapk/core => com/mapk/kmapper}/ConverterKMapperTest.kt | 3 +-- .../kotlin/{mapk/core => com/mapk/kmapper}/EnumMappingTest.kt | 3 +-- .../kotlin/{mapk/core => com/mapk/kmapper}/GetTargetTest.kt | 3 +-- .../kotlin/{mapk/core => com/mapk/kmapper}/ParamAliasTest.kt | 3 +-- .../core => com/mapk/kmapper}/PropertyNameConverterTest.kt | 3 +-- .../{mapk/core => com/mapk/kmapper}/SimpleKMapperTest.kt | 3 +-- .../{mapk/core => com/mapk/kmapper}/StringMappingTest.kt | 3 +-- 8 files changed, 8 insertions(+), 15 deletions(-) rename src/test/java/{mapk/core => com/mapk/kmapper}/StaticMethodConverter.java (94%) rename src/test/kotlin/{mapk/core => com/mapk/kmapper}/ConverterKMapperTest.kt (97%) rename src/test/kotlin/{mapk/core => com/mapk/kmapper}/EnumMappingTest.kt (93%) rename src/test/kotlin/{mapk/core => com/mapk/kmapper}/GetTargetTest.kt (98%) rename src/test/kotlin/{mapk/core => com/mapk/kmapper}/ParamAliasTest.kt (95%) rename src/test/kotlin/{mapk/core => com/mapk/kmapper}/PropertyNameConverterTest.kt (93%) rename src/test/kotlin/{mapk/core => com/mapk/kmapper}/SimpleKMapperTest.kt (99%) rename src/test/kotlin/{mapk/core => com/mapk/kmapper}/StringMappingTest.kt (90%) diff --git a/src/test/java/mapk/core/StaticMethodConverter.java b/src/test/java/com/mapk/kmapper/StaticMethodConverter.java similarity index 94% rename from src/test/java/mapk/core/StaticMethodConverter.java rename to src/test/java/com/mapk/kmapper/StaticMethodConverter.java index c0b3c26..d0cf3b0 100644 --- a/src/test/java/mapk/core/StaticMethodConverter.java +++ b/src/test/java/com/mapk/kmapper/StaticMethodConverter.java @@ -1,4 +1,4 @@ -package mapk.core; +package com.mapk.kmapper; import com.mapk.annotations.KConverter; diff --git a/src/test/kotlin/mapk/core/ConverterKMapperTest.kt b/src/test/kotlin/com/mapk/kmapper/ConverterKMapperTest.kt similarity index 97% rename from src/test/kotlin/mapk/core/ConverterKMapperTest.kt rename to src/test/kotlin/com/mapk/kmapper/ConverterKMapperTest.kt index 0cd72da..b39069c 100644 --- a/src/test/kotlin/mapk/core/ConverterKMapperTest.kt +++ b/src/test/kotlin/com/mapk/kmapper/ConverterKMapperTest.kt @@ -1,9 +1,8 @@ @file:Suppress("unused") -package mapk.core +package com.mapk.kmapper import com.mapk.annotations.KConverter -import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.DisplayName diff --git a/src/test/kotlin/mapk/core/EnumMappingTest.kt b/src/test/kotlin/com/mapk/kmapper/EnumMappingTest.kt similarity index 93% rename from src/test/kotlin/mapk/core/EnumMappingTest.kt rename to src/test/kotlin/com/mapk/kmapper/EnumMappingTest.kt index ddff018..5bccf38 100644 --- a/src/test/kotlin/mapk/core/EnumMappingTest.kt +++ b/src/test/kotlin/com/mapk/kmapper/EnumMappingTest.kt @@ -1,8 +1,7 @@ @file:Suppress("unused") -package mapk.core +package com.mapk.kmapper -import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.params.ParameterizedTest diff --git a/src/test/kotlin/mapk/core/GetTargetTest.kt b/src/test/kotlin/com/mapk/kmapper/GetTargetTest.kt similarity index 98% rename from src/test/kotlin/mapk/core/GetTargetTest.kt rename to src/test/kotlin/com/mapk/kmapper/GetTargetTest.kt index aa50a03..60d2fb1 100644 --- a/src/test/kotlin/mapk/core/GetTargetTest.kt +++ b/src/test/kotlin/com/mapk/kmapper/GetTargetTest.kt @@ -1,10 +1,9 @@ @file:Suppress("unused") -package mapk.core +package com.mapk.kmapper import com.mapk.annotations.KConstructor import com.mapk.core.KFunctionForCall -import com.mapk.kmapper.getTarget import kotlin.reflect.KFunction import kotlin.reflect.full.memberProperties import kotlin.reflect.full.primaryConstructor diff --git a/src/test/kotlin/mapk/core/ParamAliasTest.kt b/src/test/kotlin/com/mapk/kmapper/ParamAliasTest.kt similarity index 95% rename from src/test/kotlin/mapk/core/ParamAliasTest.kt rename to src/test/kotlin/com/mapk/kmapper/ParamAliasTest.kt index e9035a1..97d5f19 100644 --- a/src/test/kotlin/mapk/core/ParamAliasTest.kt +++ b/src/test/kotlin/com/mapk/kmapper/ParamAliasTest.kt @@ -1,8 +1,7 @@ -package mapk.core +package com.mapk.kmapper import com.mapk.annotations.KGetterAlias import com.mapk.annotations.KPropertyAlias -import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test diff --git a/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt b/src/test/kotlin/com/mapk/kmapper/PropertyNameConverterTest.kt similarity index 93% rename from src/test/kotlin/mapk/core/PropertyNameConverterTest.kt rename to src/test/kotlin/com/mapk/kmapper/PropertyNameConverterTest.kt index e2be121..a430430 100644 --- a/src/test/kotlin/mapk/core/PropertyNameConverterTest.kt +++ b/src/test/kotlin/com/mapk/kmapper/PropertyNameConverterTest.kt @@ -1,7 +1,6 @@ -package mapk.core +package com.mapk.kmapper import com.google.common.base.CaseFormat -import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test diff --git a/src/test/kotlin/mapk/core/SimpleKMapperTest.kt b/src/test/kotlin/com/mapk/kmapper/SimpleKMapperTest.kt similarity index 99% rename from src/test/kotlin/mapk/core/SimpleKMapperTest.kt rename to src/test/kotlin/com/mapk/kmapper/SimpleKMapperTest.kt index 23d5af2..778ff68 100644 --- a/src/test/kotlin/mapk/core/SimpleKMapperTest.kt +++ b/src/test/kotlin/com/mapk/kmapper/SimpleKMapperTest.kt @@ -1,9 +1,8 @@ @file:Suppress("unused") -package mapk.core +package com.mapk.kmapper import com.mapk.annotations.KConstructor -import com.mapk.kmapper.KMapper import java.math.BigInteger import kotlin.reflect.full.isSubclassOf import org.junit.jupiter.api.Assertions.assertEquals diff --git a/src/test/kotlin/mapk/core/StringMappingTest.kt b/src/test/kotlin/com/mapk/kmapper/StringMappingTest.kt similarity index 90% rename from src/test/kotlin/mapk/core/StringMappingTest.kt rename to src/test/kotlin/com/mapk/kmapper/StringMappingTest.kt index 7c1776a..d77e87d 100644 --- a/src/test/kotlin/mapk/core/StringMappingTest.kt +++ b/src/test/kotlin/com/mapk/kmapper/StringMappingTest.kt @@ -1,6 +1,5 @@ -package mapk.core +package com.mapk.kmapper -import com.mapk.kmapper.KMapper import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test From a6eb43442dd422205a6f2fbcd1daac231c3662f1 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 29 Feb 2020 23:15:57 +0900 Subject: [PATCH 07/13] =?UTF-8?q?CI=E3=81=AE=E3=83=90=E3=83=83=E3=83=81?= =?UTF-8?q?=E5=8F=82=E7=85=A7=E5=85=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 081984c..2727f6e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -[![CircleCI](https://circleci.com/gh/k163377/MapK.svg?style=svg)](https://circleci.com/gh/k163377/MapK) -[![](https://jitci.com/gh/k163377/MapK/svg)](https://jitci.com/gh/k163377/MapK) +[![CircleCI](https://circleci.com/gh/ProjectMapK/KMapper.svg?style=svg)](https://circleci.com/gh/ProjectMapK/KMapper) +[![](https://jitci.com/gh/ProjectMapK/KMapper/svg)](https://jitci.com/gh/ProjectMapK/KMapper) MapK ==== From d4a33ff4c1d2e7fcfcfb2fcfd8f4cc27d6298a2a Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sat, 29 Feb 2020 23:17:02 +0900 Subject: [PATCH 08/13] =?UTF-8?q?readme=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2727f6e..21af97f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CircleCI](https://circleci.com/gh/ProjectMapK/KMapper.svg?style=svg)](https://circleci.com/gh/ProjectMapK/KMapper) [![](https://jitci.com/gh/ProjectMapK/KMapper/svg)](https://jitci.com/gh/ProjectMapK/KMapper) -MapK +KMapper ==== This is a Mapper Libraly like a `ModelMapper` for `Kotlin`. You can call `KFunction`(e.g. `constructor`) from `Object`. @@ -23,7 +23,7 @@ val newInstance = KMapper(Dst::class.primaryConstructor!!).map(src) ``` ## How to use Published on JitPack. -Please see [here](https://jitpack.io/#k163377/MapK) for the introduction method. +Please see [here](https://jitpack.io/#ProjectMapK/KMapper/) for the introduction method. ## Usages ### From multiple resources From 3e655dade5d9df2537f40ed8e0af06c4e92b7ac3 Mon Sep 17 00:00:00 2001 From: wrongwrong Date: Sun, 1 Mar 2020 12:43:50 +0900 Subject: [PATCH 09/13] =?UTF-8?q?JitPack=E3=81=B8=E3=81=AE=E5=8F=82?= =?UTF-8?q?=E7=85=A7=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/jarRepositories.xml | 5 +++++ build.gradle.kts | 1 + 2 files changed, 6 insertions(+) diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index fdc392f..f5a0c5d 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -16,5 +16,10 @@