斯卡拉:注释存取方法 [英] scala: annotating accessor methods

查看:173
本文介绍了斯卡拉:注释存取方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class Foo {
  @SomeAnnotation
  var bar: String = _
}

@SomeAnnotation是一个Java注解(因此它被保持在运行时)与运行时保留和方法的目标。在code编译,但在运行时酒吧()和巴_ =()生成编译器不注解的方法。

@SomeAnnotation is a Java annotation (so it is kept at runtime) with runtime retention and Method target. The code compiles, but at runtime the bar() and bar_=() methods that the compiler generated are not annotated.

假设这是不是一个错误,有没有标注生成的getter方法​​,而无需显式可变形点焊方法的干净的方式?

Assuming this is not a bug, is there a clean way of annotating the generated getter method without needing to def the method explicitly?

推荐答案

这个邮件列表信息可能是使用:
<一href=\"http://old.nabble.com/-scala--field-annotations,-getters-setters-and-BeanProperty-td24970781.html\" rel=\"nofollow\">http://old.nabble.com/-scala--field-annotations,-getters-setters-and-BeanProperty-td24970781.html

This mailing list post might be of use: http://old.nabble.com/-scala--field-annotations,-getters-setters-and-BeanProperty-td24970781.html

这篇关于斯卡拉:注释存取方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆