java Javadoc 使用@value 显示内部类常量的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11426959/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javadoc displaying value on an inner class constant using @value
提问by eold
I have an inner class which declares a constant and want to display its value in Javadoc of the enclosing top-level class using the @value annotation. For example:
我有一个内部类,它声明了一个常量,并希望使用 @value 注释在封闭的顶级类的 Javadoc 中显示其值。例如:
/**
* {@value #FOO_CONS} // this displays well
* {@value #BAR_CONS} // this does not work (checked in the latest Eclipse)
* {@value Bar#BAR_CONS} // this does not work, either
*/
public Foo {
public static final int FOO_CONS = 1;
static class Bar {
public static final int BAR_CONS = 42;
}
}
Any ideas how to display the value of BAR_CONS in Javadoc of the Foo
class (or any other class, in general)?
任何想法如何在Foo
类(或任何其他类,一般)的Javadoc 中显示 BAR_CONS 的值?
回答by Scott
Javadoc format for constant defined in another package should be:
{@value package.class#field}
在另一个包中定义的常量的 Javadoc 格式应该是:
{@value package.class#field}
However, it potentially not rendering is a known issue:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=342194
但是,它可能无法呈现是一个已知问题:https:
//bugs.eclipse.org/bugs/show_bug.cgi?id=342194
回答by user2340612
if create javadoc for members with visibility "package" (which is the visibility for your Bar class) i get the constant in the javadoc under Foo.Bar
如果为具有可见性“包”(这是 Bar 类的可见性)的成员创建 javadoc,我会在 Foo.Bar 下的 javadoc 中得到常量