枚举类型的使用:
/**
* 描述: 数据来源
* @ClassName: SourceType
* @author liqiangping
* @date 2020年5月18日 上午10:57:38
* @version v1.0
*/
public enum SourceType {
TEAMWORK("TeamWork", "销售系统");
private String code;
private String detail;
SourceType(String code, String detail) {
this.code = code;
this.detail = detail;
}
public String getCode() {
return code;
}
public String getDetail() {
return detail;
}
//根据code类型返回系统来源信息
public static String parseSource(String code) {
SourceType[] values = SourceType.values();
for (SourceType sourceType : values) {
if (Objects.equals(sourceType.getCode(), code)) {
return sourceType.getDetail();
}
}
return "";
}
}