枚举

来源:互联网 发布:域名属于知识产权吗 编辑:程序博客网 时间:2024/06/04 18:49

course_prop  课程属性 课程属性。1:自建课程,2:商品课程,3:翻转课程。

public enum CourseProp {

SELF_COURSE(1,"SELF_COURSE"),
STORE_COURSE(2,"STORE_COURSE"),
COPY_COURSE(3,"COPY_COURSE");

private Integer value;
private String displayName;

CourseProp(Integer value, String displayName){
this.value = value;
this.displayName = displayName;
};

private static Map<Integer, String> displayNameMap = new HashMap<Integer, String>();
private static Map<String, Integer> valueMap = new HashMap<String, Integer>();
static{
for(CourseProp courseType : CourseProp.values()){
displayNameMap.put(courseType.value, courseType.getDisplayName());
valueMap.put(courseType.getDisplayName(), courseType.value);
}
}

public static String getDisplayName(Integer value){
return displayNameMap.get(value);
}

public static Integer getValue(String displayName){
return valueMap.get(displayName);
}

public Integer getValue() {
return value;
}

public String getDisplayName() {
return displayName;
}
}