简体   繁体   English

私有字段javadoc的自动传播到getter/setter?

[英]Automatic propagation of private field javadoc's to getters/setters?

I've documented my bean private fields with Javadoc, explaining what each field is for.我已经用 Javadoc 记录了我的 bean 私有字段,解释了每个字段的用途。 Can i propagate these documentations somehow to corrseponding getters/setters to reduce duplications of documentation?我可以以某种方式将这些文档传播到相应的 getter/setter 以减少文档的重复吗? Is there's some kind of Javadoc macro for this at least?至少有某种Javadoc宏吗?

You could link the javadoc comment of getters and setters to the private field by adding a javadoc link:您可以通过添加 javadoc 链接将 getter 和 setter 的 javadoc 注释链接到私有字段:

{@link Class#field}

However i would not really recommend this.但是我不会真的推荐这个。 As the previous commentators stated, i would just document the getters and setters properly.正如前面的评论员所说,我只会正确记录 getter 和 setter。 Javadoc documents your public API, which the getters and setters may belong to. Javadoc 记录您的公共 API,getter 和 setter 可能属于该文件。 Your private fields do not belong to the public API.您的私有字段不属于公共 API。

You may consider some compile-time tools like Lombok:您可以考虑一些编译时工具,例如 Lombok:

http://projectlombok.org/features/GetterSetter.html http://projectlombok.org/features/GetterSetter.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM