Better way to map Kotlin data objects to data objects
<p>I want to convert/map some "data" class objects to similar "data" class objects. For example, classes for web form to classes for database records.</p>

<pre><code>data class PersonForm(
    val firstName: String,
    val lastName: String,
    val age: Int,
    // maybe many fields exist here like address, card number, etc.
    val tel: String
)
// maps to ...
data class PersonRecord(
    val name: String, // "${firstName} ${lastName}"
    val age: Int, // copy of age
    // maybe many fields exist here like address, card number, etc.
    val tel: String // copy of tel
)
</code></pre>

<p>I use ModelMapper for such works in Java, but it can't be used because data classes are final (ModelMapper creates CGLib proxies to read mapping definitions). We can use ModelMapper when we make these classes/fields open, but we must implement features of "data" class manually.
(cf. ModelMapper examples: <a href="https://github.com/jhalterman/modelmapper/blob/master/examples/src/main/java/org/modelmapper/gettingstarted/GettingStartedExample.java" rel="noreferrer">https://github.com/jhalterman/modelmapper/blob/master/examples/src/main/java/org/modelmapper/gettingstarted/GettingStartedExample.java</a>)</p>

<p>How to map such "data" objects in Kotlin?</p>

<p><strong>Update:</strong>
ModelMapper automatically maps fields that have same name (like tel -> tel) without mapping declarations. I want to do it with data class of Kotlin.</p>

<p><strong>Update:</strong>
The purpose of each classes depends on what kind of application, but these are probably placed in the different layer of an application.</p>

<p>For example:</p>

<ul>
<li>data from database (Database Entity) to data for HTML form (Model/View Model)</li>
<li>REST API result to data for database</li>
</ul>

<p>These classes are similar, but are not the same.</p>

<p>I want to avoid normal function calls for these reasons:</p>

<ul>
<li>It depends on the order of arguments. A function for a class with many fields that have same type (like String) will be broken easily.</li>
<li>Many declarations are nesessary though most mappings can be resolved with naming convention.</li>
</ul>

<p>Of course, a library that has similar feature is intended, but information of the Kotlin feature is also welcome (like spreading in ECMAScript).</p>