0
我試圖得到一個指向自定義類屬性的類型,我只是得到它的類型對象階反射場類
我的代碼:
class Edge[N <% Node](var from : N, var to : N) {
def toXml(c: Class): xml.Elem = {
<edge>{
for(field: Field <- classOf[this.type].getDeclaredFields)
yield <field name={field.name} tpe={field.tpe.toString()}>{ this.getClass().getMethods.find(_.getName() == field.name).get.invoke(this) }</field>
}</edge>
}
所以問題這裏是我需要在java字段和scala字段之間切換:顯然在scala中沒有this.getClass這樣的東西?所以我需要通過Java來獲得課程? 但是,這似乎只會導致對象作爲類型?
我已經添加了更多的代碼和更多解釋的問題。 – user485659