Added convenience method to check Role existance by string

This commit is contained in:
Mauro Mugnaini 2021-01-27 19:35:13 +01:00
parent c75eb8af91
commit 2e0fb63ee6
1 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,8 @@
package org.gcube.oidc; package org.gcube.oidc;
import java.util.HashSet;
import java.util.Set;
public class D4ScienceMappings { public class D4ScienceMappings {
public enum Role { public enum Role {
@ -16,6 +19,8 @@ public class D4ScienceMappings {
VRE_DESIGNER("VRE-Designer"), VRE_DESIGNER("VRE-Designer"),
VRE_MANAGER("VRE-Manager"); VRE_MANAGER("VRE-Manager");
private static Set<String> STRING_VALUES;
private String str; private String str;
Role(String str) { Role(String str) {
@ -25,6 +30,22 @@ public class D4ScienceMappings {
public String asString() { public String asString() {
return str; return str;
} }
static {
STRING_VALUES = new HashSet<String>();
for (Role role : Role.values()) {
STRING_VALUES.add(role.asString());
}
}
public static Set<String> stringValues() {
return STRING_VALUES;
}
public static boolean exists(String role) {
return STRING_VALUES.contains(role);
}
} }
public enum Scope { public enum Scope {