title: How to update kotlin data class with properties of a different data class
body: <p>If I have for example an entity:</p>
  <pre><code>   data class SampleEntity(
              val a: Int,
              val b: Int,
              val c: Int,
              val d: Int){
       fun update(form: SampleEntityUpdateForm): SampleEntity{
         ... 
         return this SampleEntity updated with form
       } 
  }
  </code></pre>
  <p>and a form to update this entity:</p>
  <pre><code>data class SampleEntityUpdateForm(
          val a: Int?,
          val b: Int?,
          val c: Int?,
          val d: Int?
  )
  </code></pre>
  <p>What is the best way to update the entity with this form (i.e. implementing SampleEntity.update(...)), leaving the properties that are null in SampleEntityUpdateForm as they were in the original entity, with minimum boiler plate.</p>
  <p>So for example:</p>
  <pre><code>val sampleEntityInst = SampleEntity(1,2,3,4)
  
  val sampleEntityUpdateForm(b = 20, d = 40)
  
  val updatedSampleEntityInst = sampleEntityInst.update(sampleEntityUpdateForm)
  </code></pre>
  <p>where updatedSampleEntityInst will equal SampleEntity(1,20,3,40).</p>
  <p>obviosly I could implement SampleEntity.update as:</p>
  <pre><code>fun update(form: SampleEntityUpdateForm) = SampleEntity(
          a = form.a ?: this.a,
          b = form.b ?: this.b,
          c = form.c ?: this.c,
          d = form.d ?: this.d,
  )
  </code></pre>
  <p>But this has quite a bit of boiler plate/repetition. Is there something already made to allow doing this with less boiler plate/repetition?</p>