Kawai Wiki

Rev

Rev 149 | 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
 
194 helio.frota 6
/**
7
 * Enum Group.
8
 *
9
 * @author Sergio Oliveira
10
 *
11
 */
6 soliveira 12
public enum Group {
13
 
194 helio.frota 14
    ADMIN(1, "Admin"), EDITOR(2, "Editor");
6 soliveira 15
 
194 helio.frota 16
    /** Attribute id of Group. */
17
    private int id;
18
    /** Attribute name of Group. */
19
    private String name;
20
 
138 soliveira 21
    private Group(int code, String name) {
194 helio.frota 22
        this.id = code;
23
        this.name = name;
6 soliveira 24
    }
25
 
27 soliveira 26
    public int getId() {
194 helio.frota 27
        return id;
6 soliveira 28
    }
194 helio.frota 29
 
138 soliveira 30
    public String getName() {
194 helio.frota 31
        return name;
138 soliveira 32
    }
194 helio.frota 33
 
27 soliveira 34
    public static Group fromId(int id) {
194 helio.frota 35
        for(Group g : Group.values()) {
36
            if (g.getId() == id) {
37
                return g;
38
            }
39
        }
40
        return null;
6 soliveira 41
    }
194 helio.frota 42
 
138 soliveira 43
    public static ListData getListData() {
194 helio.frota 44
        SimpleListData list = new SimpleListData("groups");
45
        for(Group g : Group.values()) {
46
            list.add(g.getId(), g.getName());
47
        }
48
        return list;
138 soliveira 49
    }
6 soliveira 50
}