Eclipse自定义注释
观前提示:
本文所使用的Eclipse版本为Photon Release (4.8.0)。
在使用Eclipse过程中,我们经常会使用到注释(类注释,方法注释……),但是每一次都手动添加@ClassName@Description这些自定义注释又会显得过于麻烦,这个时候,我们便可以自定义这些模板。
选择Window->Preferences
选择Java->Code Style->Code Templates自定义模板
1.文件(Flies)注释
选择Comments->Files->Edit
改写为以下内容
/**
* All rights Reserved, Designed By 公司名
* @Title: ${file_name}
* @Package ${package_name}
* @Description: ${todo}(用一句话描述该文件做什么)
* @author: XXX
* @date: ${date} ${time}
* @version V1.0
* @Copyright: ${year} 公司名 Inc. All rights reserved.
*/
2.类型(Types)注释
选择Comments->Types->Edit
改写为以下内容
/**
* @ClassName: ${type_name}
* @Description:${todo}(这里用一句话描述这个类的作用)
* @author:XXX
* @date:${date} ${time}
*/
3.字段(Fields)注释
选择Comments->Fields->Edit
改写为以下内容
/**
* @Fields ${field} : ${todo}(用一句话描述这个变量表示什么)
*/
4.构造函数(Constructors)注释
选择Comments->Constructors->Edit
改写为以下内容
/**
* @Title: ${enclosing_type}
* @Description:${todo}(这里用一句话描述这个方法的作用)
* @param:${tags}
* @throws
*/
5.方法(Methods)注释
选择Comments->Methods->Edit
改写为以下内容
/**
* @Title: ${enclosing_method}
* @Description: ${todo}(这里用一句话描述这个方法的作用)
* ${tags}
* @Create: ${date} ${time} by XXX
*/
6.覆盖方法(Overriding Methods)注释
选择Comments->Overriding Methods->Edit
改写为以下内容
/**
* @Title: ${enclosing_method}
* @Description: ${todo}(这里用一句话描述这个方法的作用)
* ${tags}
* @Create: ${date} ${time}
* ${see_to_overridden}
*/
7.代表方法(Delegate Methods)注释
选择Comments->Delegate Methods->Edit
改写为以下内容
/**
* ${tags}
* ${see_to_target}
*/
8.Getter方法注释
选择Comments->Getter->Edit
改写为以下内容
/**
* @Title: ${enclosing_method}
* @Description: Get方法
* @return: ${field_type}
*/
9.Setter方法注释
选择Comments->Setter->Edit
改写为以下内容
/**
* @Title: ${enclosing_method}
* @Description: Set方法
* @return: ${field_type}
*/