title: How to model schema.org in Scala?
body: <p><a href="http://www.schema.org" rel="nofollow">Schema.org</a> is markup vocabulary (for the web) and defines a number of types in terms of properties (no methods). I am currently trying to model parts of that schema in Scala as internal model classes to be used in conjunction with a document-oriented database (MongoDB) and a web framework.</p>
  
  <p>As can be seen in the definition of <a href="http://schema.org/LocalBusiness" rel="nofollow">LocalBusiness</a>, schema.org uses multiple inheritance to also include properties from the "Place" type. So my question is: <strong>How would you model such a schema in Scala?</strong></p>
  
  <p>I have come up with two solutions so far. The first one use regular classes to model a single inheritance tree and uses traits to mixin those additional properties.</p>
  
  <pre><code>trait ThingA {
    var name: String = ""
    var url: String = ""
  }
  
  trait OrganizationA {
    var email: String = ""
  }
  
  trait PlaceA {
    var x: String = ""
    var y: String = ""
  }
  
  trait LocalBusinessA {
    var priceRange: String = ""
  }
  
  class OrganizationClassA extends ThingA with OrganizationA {}
  
  class LocalBusinessClassA extends OrganizationClassA with PlaceA with LocalBusinessA {}
  </code></pre>
  
  <p>The second version tries to use case classes. However, since case class inheritance is deprecated, I cannot model the main hierarchy so easily.</p>
  
  <pre><code>trait ThingB {
    val name: String
  }
  
  trait OrganizationB {
    val email: String
  }
  
  trait PlaceB {
    val x: String
    val y: String
  }
  
  trait LocalBusinessB {
    val priceRange: String
  }
  
  case class OrganizationClassB(val name: String, val email: String) extends ThingB with OrganizationB
  
  case class LocalBusinessClassB(val name: String, val email: String, val x: String, val y: String, val priceRange: String) extends ThingB with OrganizationB with PlaceB with LocalBusinessB
  </code></pre>
  
  <p><strong>Is there a better way to model this?</strong> I could use composition similar to</p>
  
  <pre><code>case class LocalBusinessClassC(val thing:ThingClass, val place: PlaceClass, ...)
  </code></pre>
  
  <p>but then of course, LocalBusiness cannot be used when a "Place" is expected, for example when I try to render something on Google Maps.</p>