访问器只是名为
name
name_$eq
所以你也可以用Java来实现:
scala> val c = classOf[Entity]
c: java.lang.Class[Entity] = class Entity
scala> c.getDeclaredMethod("name_$eq", classOf[String])
res0: java.lang.reflect.Method = public void Entity.name_$eq(java.lang.String)
scala> c.getDeclaredMethod("name")
res1: java.lang.reflect.Method = public java.lang.String Entity.name()