- 场景
当一个类属性需要映射一个枚举类时,常常需要写上注释,不美观且麻烦
public enum MyType {
TYPE1("1","类型1"),
TYPE2("2","类型2");
private String code;
private String name;
MyType(String code, String name) {
this.code = code;
this.name = name;
}
}
public class Ann {
// 1-类型1 2- 类型2
private String myType;
}
- @see/@link
public class Ann {
/**
* @see com.ann.MyType
*/
private String myType;
}
或者
public class Ann {
/**
* {@link com.ann.MyType}
*/
private String myType;
}
这样就能通过鼠标点击枚举类,直接跳转过去,查看到相应的映射,方便多了