leomon
5 days ago 6017102b1d6affc7255e9f2df6f9e45e0b1a75fb
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.oying.modules.message.common;
 
import lombok.AllArgsConstructor;
import lombok.Getter;
 
@Getter
@AllArgsConstructor
public enum PlatFormEnum {
    //1=买家 2=商户 3=骑手"
    BUYER(1, "买家"),
    MERCHANT(2, "商户"),
    RIDE(3, "骑手");
 
    private final Integer key;
    private final String value;
 
    /**
     * 根据key获取枚举实例
     * @param key key值
     * @return 对应的枚举实例,未找到返回null
     */
    public static PlatFormEnum getByKey(Integer key) {
        if (key == null) {
            return null;
        }
        for (PlatFormEnum platFormEnum : PlatFormEnum.values()) {
            if (platFormEnum.key.equals(key)) {
                return platFormEnum;
            }
        }
        return null;
    }
 
    /**
     * 根据value获取枚举实例
     * @param value value值
     * @return 对应的枚举实例,未找到返回null
     */
    public static PlatFormEnum getByValue(String value) {
        if (value == null) {
            return null;
        }
        for (PlatFormEnum platFormEnum : PlatFormEnum.values()) {
            if (platFormEnum.value.equals(value)) {
                return platFormEnum;
            }
        }
        return null;
    }
 
    @Override
    public String toString() {
        return "PlatFormEnum{" +
                "key=" + key +
                ", value='" + value + '\'' +
                ", name='" + this.name() + '\'' +
                '}';
    }
}