注释的 Scala 类型别名 [英] Scala Type aliases for annotations

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

问题描述

在我的代码的很多地方,三个注解一起出现:

In many points of my code, three annotations appears together:

@BeanProperty
@(SpaceProperty @beanGetter)(nullValue="0")

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

where nullValue="0" is a parameter to the annotation SpaceProperty.

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

Is it possible to define a single type alias for @BeanProperty @(SpaceProperty @beangetter) ?

我能做的最好的是:

type ScalaSpaceProperty = SpaceProperty @beanGetter

@BeanProperty
@(ScalaSpaceProperty)(nullValue = "0")

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

Is it possible to define a type alias for two annotations where the parameters are applied to the last one?

推荐答案

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

No. You can write a macro to do this in Scala 2.10, I think (but the documentation isn't available at the moment, so I can't check).

这篇关于注释的 Scala 类型别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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