Enum使用实践

1.用于处理常量, 增强代码可读性

Enum类

**Constant

//使用tableName映射IdName
public enum **Constant{
	//成员常量
	CH_ADMIN_GELP_FAQ("F_ID");
    CH_ADMIN_GELP_DOC("D_ID");
    CH_ADMIN_GELP_VIDEO("V_ID");


	//成员变量
	private String idName;

	public Strng getIdName(){
		return idNAme;
	}
		
	IdNameConstant(String idName){
		this.idName=idName;
	}

}

Service

@Override
public String  updateAdminLiseDataSequence(SequenceDto request) throw Exception{
	IdNameConstant idNameCon = **Constant.valueof(request.getTableName.toUpperCase());
	String tableName = IdNameCon.name();
	String idName = IdNameCon.getIdName();
	//...
}

你可能感兴趣的:(java)