是否有工具使用 hamcrest Factory 注释?
今天我坐下来编写一个匹配器,并决定快速浏览一下 jmock 文档以刷新我对该过程的记忆,并注意到对 org.hamcrest.Factory 注释的引用。注释的文档说明了这一点。
标记 Hamcrest 静态工厂方法,以便工具识别它们。工厂方法相当于命名构造函数。
是否有任何工具实际使用此注释?
I sat down to write a matcher today and decided to take a quick look at the jmock documentation to refresh my memory on the process, and noticed a reference to the org.hamcrest.Factory annotation. The documentation for the annotation states.
Marks a Hamcrest static factory method so tools recognise them. A factory method is an equivalent to a named constructor.
Do any tools actually use this annotation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如Hamcrest 教程中所述,
Factory
注解由 Hamcrest 代码生成器 org.hamcrest.generator.config.XmlConfigurator 使用。它生成一个 Java 源文件,其中包含一组配置的类中的所有工厂,以便您可以使用单个静态导入来静态导入所有这些工厂。我还没有使用过这个功能,因为我在编写匹配器后就手动将自己编写的匹配器收集到工厂类中,并且在使用时我自己静态导入每个工厂方法(使用 Eclipse 的“收藏夹”功能自动导入) -进口)。
As explained in the Hamcrest tutorial, the
Factory
annotation is used by a Hamcrest code generator,org.hamcrest.generator.config.XmlConfigurator
. It generates a Java source file that contains all factories from a configured set of classes, so that you can statically import all of them by using a single static import.I have not used this feature yet, because I manually collect my self-written matchers in a factory class as soon as I write the matcher, and on usage I statically import each factory method by itself (using the Eclipse "Favorites" feature for auto-import).