Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PermissionType.java « enums « model « deck « nextcloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 49f10ef24730bf92f67cce82b7c50d136d97f2d7 (plain)
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
package it.niedermann.nextcloud.deck.model.enums;

public enum PermissionType {

    READ(1, "PERMISSION_READ"),
    EDIT(2, "PERMISSION_EDIT"),
    MANAGE(3, "PERMISSION_MANAGE"),
    SHARE(4, "PERMISSION_SHARE");

    private long id;
    private String key;

    PermissionType(long id, String key) {
        this.key = key;
    }

    public static PermissionType findByKey(String key) {
        for (PermissionType s : PermissionType.values()) {
            if (s.getKey().equals(key)) {
                return s;
            }
        }
        throw new IllegalArgumentException("unknown Permission key");
    }

    public static PermissionType findById(long key) {
        for (PermissionType s : PermissionType.values()) {
            if (s.getId() == key) {
                return s;
            }
        }
        throw new IllegalArgumentException("unknown Permission ID");
    }

    public String getKey() {
        return key;
    }

    public long getId() {
        return id;
    }
}