Scala类型注释的别名

Edm*_*984 10 java annotations scala

在我的代码的许多方面,三个注释一起出现:

@BeanProperty
@(SpaceProperty @beanGetter)(nullValue="0")
Run Code Online (Sandbox Code Playgroud)

where nullValue="0"是注释的参数SpaceProperty.

是否可以为单个类型别名定义@BeanProperty @(SpaceProperty @beangetter)

我能做的最好的事情是:

type ScalaSpaceProperty = SpaceProperty @beanGetter

@BeanProperty
@(ScalaSpaceProperty)(nullValue = "0")
Run Code Online (Sandbox Code Playgroud)

是否可以为两个注释定义一个类型别名,其中参数应用于最后一个?

Ale*_*nov 4

不,我认为您可以在 Scala 2.10 中编写一个宏来执行此操作(但目前没有文档,因此我无法检查)。

  • 在 2.10.0 中您无法为此编写宏。也许这个功能会进入 2.10.1,但我不确定。 (7认同)