55KMapper
66====
77This is a Mapper Libraly like a ` ModelMapper ` for ` Kotlin ` .
8- You can call ` KFunction ` (e.g. ` constructor ` ) from ` Object ` .
8+ You can call ` KFunction ` (e.g. ` method reference ` ) from ` Object ` .
99
1010``` kotlin
1111// before
@@ -39,6 +39,8 @@ class Dst(
3939 val arg4 : Double ,
4040 val arg5 : String?
4141)
42+
43+ val newInstance = KMapper (::Dst ).map(src1, src2, src3)
4244```
4345
4446### Set alias on map
@@ -47,6 +49,8 @@ class Dst(
4749class Src (@KGetterAlias(" aliased" ) val str : String )
4850
4951class Dst (val aliased : String )
52+
53+ val newInstance = KMapper (::Dst ).map(src)
5054```
5155
5256#### for parameter
@@ -56,6 +60,8 @@ class Src(val str: String)
5660class Dst (@param:KPropertyAlias("str") private val _src : String ) {
5761 val src = _src .someArrangement
5862}
63+
64+ val newInstance = KMapper (::Dst ).map(src)
5965```
6066
6167### Convert parameter name
@@ -64,7 +70,7 @@ val srcMap = mapOf("snake_case" to "SnakeCase")
6470
6571class Dst (val snakeCase : String )
6672
67- val dst: Dst = Mapper (::DataClass ) { it.toSnakeCase }.map(src)
73+ val dst: Dst = KMapper (::DataClass ) { camelToSnake(it) }.map(src)
6874```
6975
7076### Map param to another class
@@ -82,4 +88,6 @@ class CreatorClass @SingleArgCreator constructor(val arg: String) {
8288class Src (val arg1 : String , val arg2 : Int )
8389
8490class Dst (val arg1 : CreatorClass , val arg2 : CreatorClass )
91+
92+ val newInstance = KMapper (::Dst ).map(src)
8593```
0 commit comments