有没有办法在 Scala 中创建自定义注释并编写自定义注释处理器来验证注释? [英] Is there a way to create custom annotations in Scala and write a custom annotation processor to verify the annotations?
问题描述
我一直在学习注释以及注释处理器是什么.我正在查看 Java 示例,似乎有一种正确的方法可以做到这一点.但是,在 Scala 中,我没有合适的网站/文档来创建自定义注释和注释处理器.
I have been learning about annotations and what an annotation processor is. I was looking at Java examples and there seems to be a proper way to do it. However, in Scala, I do not get a proper website/documentation to create custom annotations and annotation processor.
如果在 Scala 中不可能,有没有办法在 Scala 类中使用 Java 自定义注释处理器?
If it's not possible in Scala, is there a way to use Java custom annotation processor in Scala classes?
有人能指出我正确的方向吗?
Can someone point me in the right direction?
推荐答案
Scala 中有宏注解
In Scala there are macro annotations
https://docs.scala-lang.org/overviews/macros/annotations.html
我猜这类似于 Java 中的编译时处理注释.
I guess this is similar to compile-time processing annotations in Java.
这篇关于有没有办法在 Scala 中创建自定义注释并编写自定义注释处理器来验证注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!