有没有一种方法可以在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屋!