title: Is there a way to require a generic type to be a data class in Kotlin?
body: <p>The following does not work, but hopefully helps you understand what I mean:</p>
  
  <pre><code>class Example&lt;T : DataClass&gt;
  </code></pre>
  
  <p>In case you would like to know what I am trying to accomplish, this is an example of what I had in mind:</p>
  
  <pre><code>class Repository&lt;T&gt; where T : Entity, // Entity defines mutable property 'id'
                            T : DataClass {
  
    // assume there is a map here
  
    fun add(obj: T) {
      val copy = obj.copy(id = generateID())
      map.put(copy.id, copy)
    }
  
  }
  </code></pre>
  
  <p>Or is there a better way to accomplish what I am trying to do?</p>