shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
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
60
61
package com.walker.web;
 
/**
 * 数据状态枚举类型
 * @author 时克英
 * @date 2018-11-29
 *
 */
public enum DataStatus {
 
    /**
     * 正常状态数据:1
     */
    Normal{
        public int getTypeValue(){
            return CONST_NORMAL;
        }
    },
    
    /**
     * 禁用状态数据:0
     */
    Disable{
        public int getTypeValue(){
            return CONST_DISABLE;
        }
    },
    
    /**
     * 删除状态数据:-1
     */
    Deleted {
        public int getTypeValue(){
            return CONST_DELETED;
        }
    };
    
    public static final int CONST_NORMAL = 0;
    public static final int CONST_DISABLE = 1;
    public static final int CONST_DELETED = 2;
    
    /**
     * 返回枚举类型值
     * @return
     */
    public int getTypeValue(){
        throw new AbstractMethodError();
    }
    
    public static DataStatus getType(int index){
        if(index == CONST_NORMAL){
            return Normal;
        } else if(index == CONST_DISABLE){
            return Disable;
        } else if(index == CONST_DELETED){
            return Deleted;
        } else
            throw new IllegalArgumentException("unsupported DataStatus: " + index);
    }
    
}