dcp*_*dcp 6 java eclipse code-generation
在eclipse中实现接口时,它有一个非常好的功能,可以让你"添加未实现的方法",它将为接口方法生成方法存根.
但是,它没有带来接口方法的方法文档,我想知道是否有办法让eclipse这样做.
这就是我想要发生的事情.假设我有一个这样的界面:
public interface BaseInterface {
/**
* This method takes the given string parameter and returns its integer value.
*
* @param x the string to convert
* @return the integer value of the string
*
* @throws Exception if some error occurs
*/
int method1(String x);
}
Run Code Online (Sandbox Code Playgroud)
现在我创建一个名为MyClass的类来实现这个接口.我想要发生的是,当我说"添加未实现的方法"时,我希望我的代码看起来像这样:
public class MyClass implements BaseInterface {
/**
* This method takes the given string parameter and returns its integer value.
*
* @param x the string to convert
* @return the integer value of the string
*
* @throws Exception if some error occurs
*/
public int method1(String x) {
return 0;
}
}
Run Code Online (Sandbox Code Playgroud)
是的:这些方法是使用您编写的代码模板生成的.
你必须进入"窗口/首选项 - > Java /代码样式/代码模板"
然后,在列表中选择"注释/覆盖方法",并使用在"注释/方法"中找到的内容更改内容:
/**
* ${tags}
*/
Run Code Online (Sandbox Code Playgroud)
您甚至可以考虑添加${see_to_overridden}一个直接链接到原始方法.但是,请注意,没有javadoc的方法会自动从其覆盖的方法继承其javadoc,因此这样的模板可能会生成与默认行为不太相关的文档.
| 归档时间: |
|
| 查看次数: |
2935 次 |
| 最近记录: |