Generate a case class definition?

16 views
Skip to first unread message

Julian Peeters

unread,
May 3, 2013, 3:04:18 AM5/3/13
to scala...@googlegroups.com
I'm trying to avoid hand-coding gnarly model definitions.  For example, say I need to deserialize an object from a collection that I didn't create.  Is there a recommended approach?

I have a sub-optimal proto-solution here. I was curious to see just how dynamic I could make it. I used objectWeb's ASM to dynamically generate a case class at runtime, but had to resort to a class hierarchy so I could use the concrete class type of the parent as a type parameter for the grater.  I'd rather not use a hierarchy, but I'm currently limited because the dynamic class appears to be loaded as `Class[?0]`, and I don't know how to properly type it.  I wish I knew more about how Salat used Product and ScalaSig, because both appear accessible to me in the Dump.scala files that generate the case class bytecode.  

So to reiterate, 
  1. Do y'all ever need to generate case classes? How do you do it?
  2. Is what I want to do totally unsafe and heinous and I just don't know better?
  3. Is there a way to properly type my dynamically loaded class without using a hierarchy?
Thanks very much for your input,
-Julian
Reply all
Reply to author
Forward
0 new messages