Altering property lookup for Scala

Skip to end of metadata
Go to start of metadata

Sriram Srinivasan contributed this Scala code that lets you directly access scala properties. It's a model adapter that adds a lookup for a method called "foo()" when the property name is "foo". The problem is using classes in scala with the extremely convenient case class:

case class Person(name: String, salary: Double)

This creates a class of the form

class Person {  public String name(),  public String name(String)}

etc. 

Sriram could make scala to generate beans style accessors. For that he would have to do the much uglier: 

case class Person(@BeanProperty name: String, @BeanProperty salary: Double)

Anyway, the following code shows how to create an adapter that works better with Scala.

Labels: