Add method to check if configured value is a group reference

Change-Id: Ieff950a4867b5e97bee2aa663e9db6023f73655e
This commit is contained in:
Hugo Arès
2017-06-19 11:11:33 -04:00
parent aab5fbdf0d
commit 2c8f60591a
3 changed files with 7 additions and 3 deletions

View File

@@ -30,6 +30,10 @@ public class GroupReference implements Comparable<GroupReference> {
return new GroupReference(group.getGroupUUID(), group.getName());
}
public static boolean isGroupReference(String configValue) {
return configValue != null && configValue.startsWith(PREFIX);
}
public static GroupReference fromString(String ref) {
String name = ref.substring(ref.indexOf("[") + 1, ref.lastIndexOf("/")).trim();
String uuid = ref.substring(ref.lastIndexOf("/") + 1, ref.lastIndexOf("]")).trim();

View File

@@ -238,7 +238,7 @@ public class PermissionRule implements Comparable<PermissionRule> {
src = src.substring("+force ".length()).trim();
}
if (mightUseRange && !src.startsWith(GroupReference.PREFIX)) {
if (mightUseRange && !GroupReference.isGroupReference(src)) {
int sp = src.indexOf(' ');
String range = src.substring(0, sp);
@@ -254,7 +254,7 @@ public class PermissionRule implements Comparable<PermissionRule> {
src = src.substring(sp + 1).trim();
}
if (src.startsWith(GroupReference.PREFIX)) {
if (GroupReference.isGroupReference(src)) {
src = src.substring(6).trim();
GroupReference group = new GroupReference();
group.setName(src);