Extract group reference prefix into a constant

Change-Id: I73efed5cb5cf5264b4bb9826a3a36120657f1e64
This commit is contained in:
Hugo Arès
2017-06-19 10:47:16 -04:00
parent 62469e1f56
commit aab5fbdf0d
3 changed files with 7 additions and 4 deletions

View File

@@ -18,6 +18,9 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
/** Describes a group within a projects {@link AccessSection}s. */
public class GroupReference implements Comparable<GroupReference> {
public static final String PREFIX = "group ";
/** @return a new reference to the given group description. */
public static GroupReference forGroup(AccountGroup group) {
return new GroupReference(group.getGroupUUID(), group.getName());

View File

@@ -204,7 +204,7 @@ public class PermissionRule implements Comparable<PermissionRule> {
r.append(' ');
}
r.append("group ");
r.append(GroupReference.PREFIX);
r.append(getGroup().getName());
return r.toString();
@@ -238,7 +238,7 @@ public class PermissionRule implements Comparable<PermissionRule> {
src = src.substring("+force ".length()).trim();
}
if (mightUseRange && !src.startsWith("group ")) {
if (mightUseRange && !src.startsWith(GroupReference.PREFIX)) {
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("group ")) {
if (src.startsWith(GroupReference.PREFIX)) {
src = src.substring(6).trim();
GroupReference group = new GroupReference();
group.setName(src);