You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
975 B

package com.yuxue.enumtype;
public enum Direction {
VERTICAL("VERTICAL","垂直"),
HORIZONTAL("HORIZONTAL","水平"),
UNKNOWN("UNKNOWN","未知");
public final String code;
public final String desc;
Direction(String code, String desc) {
this.code = code;
this.desc = desc;
}
public static String getDesc(String code) {
Direction[] enums = values();
for (Direction type : enums) {
if (type.code().equals(code)) {
return type.desc();
}
}
return null;
}
public static String getCode(String desc) {
Direction[] enums = values();
for (Direction type : enums) {
if (type.desc().equals(desc)) {
return type.code();
}
}
return null;
}
public String code() {
return this.code;
}
public String desc() {
return this.desc;
}
}