Kawai Wiki

Rev

Rev 138 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8 soliveira 1
package org.kawai.model;
6 soliveira 2
 
138 soliveira 3
import org.mentawai.list.ListData;
4
import org.mentawai.list.SimpleListData;
5
 
6 soliveira 6
public enum Group {
7
 
138 soliveira 8
        ADMIN(1, "Admin"), EDITOR(2, "Editor");
6 soliveira 9
 
27 soliveira 10
        private int id;
138 soliveira 11
        private String name;
6 soliveira 12
 
138 soliveira 13
    private Group(int code, String name) {
27 soliveira 14
        this.id = code;
138 soliveira 15
        this.name = name;
6 soliveira 16
    }
17
 
27 soliveira 18
    public int getId() {
19
        return id;
6 soliveira 20
    }
21
 
138 soliveira 22
    public String getName() {
23
        return name;
24
    }
25
 
27 soliveira 26
    public static Group fromId(int id) {
6 soliveira 27
        for(Group g : Group.values()) {
27 soliveira 28
                if (g.getId() == id) {
6 soliveira 29
                        return g;
30
                }
31
        }
32
        return null;
33
    }
138 soliveira 34
 
35
    public static ListData getListData() {
149 soliveira 36
        SimpleListData list = new SimpleListData("groups");
138 soliveira 37
        for(Group g : Group.values()) {
38
                list.add(g.getId(), g.getName());
39
        }
40
        return list;
41
    }
6 soliveira 42
}