argos/dmp-backend/web/src/main/java/eu/eudat/types/Authorities.java

41 lines
944 B
Java
Raw Normal View History

2018-01-31 16:39:16 +01:00
package eu.eudat.types;
import java.util.Arrays;
import java.util.List;
2018-02-01 10:08:06 +01:00
2018-01-31 16:39:16 +01:00
public enum Authorities {
USER(0), MANAGER(1), ADMIN(2), DATASET_PROFILE_MANAGER(3), ANONYMOUS(99);
2018-01-31 16:39:16 +01:00
private Integer value;
private Authorities(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static Authorities fromInteger(Integer value) {
switch (value) {
case 0:
return USER;
case 1:
return MANAGER;
case 2:
return ADMIN;
case 3:
return DATASET_PROFILE_MANAGER;
2018-08-24 17:21:02 +02:00
case 99:
return ANONYMOUS;
2018-01-31 16:39:16 +01:00
default:
throw new RuntimeException("Unsupported Authority Type");
}
}
2018-02-16 11:34:02 +01:00
public static List<Authorities> all() {
return Arrays.asList(USER, ADMIN, MANAGER, DATASET_PROFILE_MANAGER);
2018-01-31 16:39:16 +01:00
}
}