title: case class Java bean combination -how to avoid some boilerplate
body: <p>I have a <code>case class</code> like this</p>
  
  <pre><code>  case class MyModel(category:Option[String],deploymentId:Option[String],key:Option[String],metaInfo:Option[String],name:Option[String],version:Option[Int],tenantId:Option[String])
  </code></pre>
  
  <p>There is a Java library, our app is interacting with which returns Java Bean. Now on many occasions have to populate Java Bean from <code>MyModel</code> <code>case class</code> e.g.</p>
  
  <pre><code>    val javaModel = repositoryService.newModel()
  
      myModel.category.map(javaModel.setCategory(_))
      myModel.deploymentId.map(javaModel.setDeploymentId(_))
      myModel.key.map(javaModel.setKey(_))
      myModel.metaInfo.map(javaModel.setMetaInfo(_))
      myModel.name.map(javaModel.setName(_))
      myModel.tenantId.map(javaModel.setTenantId(_))
      myModel.version.map(javaModel.setVersion(_))
  
      repositoryService.saveModel(javaModel)
  </code></pre>
  
  <p>Above is shorten snippet but it gets quite versbose with a ton of other properties in <code>MyModel</code> which corrosponds to <code>javaModel</code>. I am trying to come up with a generic function which iterates through <code>case class</code> (<code>MyModel</code>) and finds property names from <code>case class</code> members and calls appropriate <code>setter</code> on <code>javaModel</code> Java bean. </p>
  
  <p>I know I can use <a href="https://github.com/milessabin/shapeless" rel="nofollow">Shapeless</a> for getting all <code>keys</code> (property names) from <code>case class</code> as follow</p>
  
  <pre><code>val modelLabel = LabelledGeneric[MyModel]
  val modelKeys = Keys[modelLabel.Repr].apply
  </code></pre>
  
  <p>Now I am wondering if there is a way to use <code>modelKey</code> e.g. say when it finds <code>category</code>, when <code>mapping</code> over <code>modelKeys</code>, call appropriate <code>set</code> method on <code>javaModel</code>. e.g. for <code>category</code> it'll be calling <code>setCategory</code> and likewise for other properties (this may sound odd but preferably without using reflection? )</p>