Merge "Display error if modifying access rights for a ref is forbidden"

This commit is contained in:
Shawn Pearce
2012-06-19 17:27:00 -07:00
committed by gerrit code review
8 changed files with 110 additions and 4 deletions

View File

@@ -118,4 +118,13 @@ public class AccessSection extends RefConfigSection implements
public String toString() {
return "AccessSection[" + getName() + "]";
}
@Override
public boolean equals(final Object obj) {
if (!super.equals(obj) || !(obj instanceof AccessSection)) {
return false;
}
return new HashSet<Permission>(permissions).equals(new HashSet<Permission>(
((AccessSection) obj).permissions));
}
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.common.data;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -220,4 +221,23 @@ public class Permission implements Comparable<Permission> {
int index = NAMES_LC.indexOf(a.getName().toLowerCase());
return 0 <= index ? index : NAMES_LC.size();
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof Permission)) {
return false;
}
final Permission other = (Permission) obj;
if (!name.equals(other.name) || exclusiveGroup != other.exclusiveGroup) {
return false;
}
return new HashSet<PermissionRule>(rules)
.equals(new HashSet<PermissionRule>(other.rules));
}
@Override
public int hashCode() {
return name.hashCode();
}
}

View File

@@ -257,4 +257,19 @@ public class PermissionRule implements Comparable<PermissionRule> {
}
return Integer.parseInt(value);
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof PermissionRule)) {
return false;
}
final PermissionRule other = (PermissionRule)obj;
return action.equals(other.action) && force == other.force
&& min == other.min && max == other.max && group.equals(other.group);
}
@Override
public int hashCode() {
return group.hashCode();
}
}

View File

@@ -48,4 +48,17 @@ public abstract class RefConfigSection {
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(final Object obj) {
if (!(obj instanceof RefConfigSection)) {
return false;
}
return name.equals(((RefConfigSection) obj).name);
}
@Override
public int hashCode() {
return name.hashCode();
}
}