枚举类的创建
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.StringUtils;
@Getter
@AllArgsConstructor
public enum TypeEnum {
CODE_1("1", "成品销售"),
CODE_2("2", "材料销售"),
CODE_3("3", "成品入库"),
CODE_4("4","材料入库");
String value;
String desc;`
public static StockApplicationBizTypeEnum getEnumByValue(String value) {
StockApplicationBizTypeEnum[] arr$ = values();
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; ++i$) {
StockApplicationBizTypeEnum t = arr$[i$];
if (!StringUtils.isEmpty(value)&&value.equals(t.getValue())) {
return t;
}
}
return null;
}}`
枚举类的使用
String type = TypeEnum.getEnumByValue("2").getDesc()//type为 ‘材料销售’