xiangpei
6 小时以前 1cdb060a8aa59b0979f7609db1781805528e76e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package cn.lili.modules.goods.entity.enums;
 
/**
 * 库存操作类型
 */
public enum GoodsStockTypeEnum {
 
 
    SUB("减"),
 
    ADD("增");
 
    private final String description;
 
    GoodsStockTypeEnum(String description) {
        this.description = description;
    }
 
    public String getDescription() {
        return description;
    }
    // 根据描述获取枚举实例
    public static GoodsStockTypeEnum fromDescription(String description) {
        for (GoodsStockTypeEnum type : GoodsStockTypeEnum.values()) {
            if (type.getDescription().equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("No matching enum constant for description: " + description);
    }
 
}