Remove ID from LabelType

Labels are completely uniquely identified by name; IDs were only left
so ID or label name would be recognized in PatchSetApproval's
categoryId to facilitate online data migration. By this commit,
migration must have finished.

Change-Id: I761cd39cf02fe8c63f246dd588500d53a4acc3b0
This commit is contained in:
Dave Borowitz
2013-03-01 13:48:22 -08:00
parent 2d998f3b4f
commit 8cc723e4cd
5 changed files with 66 additions and 61 deletions

View File

@@ -33,16 +33,6 @@ public class LabelType {
return new LabelType(name, values);
}
private static String checkId(String id) {
if ("SUBM".equals(id)) {
throw new IllegalArgumentException("Reserved label ID \"" + id + "\"");
}
if (id != null && id.length() > 4) {
throw new IllegalArgumentException("Illegal label ID \"" + id + "\"");
}
return id;
}
private static String checkName(String name) {
if ("SUBM".equals(name)) {
throw new IllegalArgumentException(
@@ -102,7 +92,6 @@ public class LabelType {
}
protected String name;
protected String id;
protected String abbreviatedName;
protected String functionName;
@@ -143,20 +132,7 @@ public class LabelType {
return name;
}
@Deprecated
public String getId() {
return id;
}
@Deprecated
public void setId(String id) {
this.id = checkId(id);
}
public boolean matches(PatchSetApproval psa) {
if (id != null && psa.getLabelId().get().equals(id)) {
return true;
}
return psa.getLabelId().get().equalsIgnoreCase(name);
}

View File

@@ -26,7 +26,6 @@ import java.util.Map;
public class LabelTypes {
protected List<LabelType> labelTypes;
private transient Map<String, LabelType> byLabel;
private transient Map<String, LabelType> byId;
private transient Map<String, Integer> positions;
protected LabelTypes() {
@@ -42,8 +41,7 @@ public class LabelTypes {
}
public LabelType byLabel(LabelId labelId) {
LabelType t = byId().get(labelId.get());
return t != null ? t : byLabel().get(labelId.get().toLowerCase());
return byLabel().get(labelId.get().toLowerCase());
}
public LabelType byLabel(String labelName) {
@@ -62,20 +60,6 @@ public class LabelTypes {
return byLabel;
}
private Map<String, LabelType> byId() {
if (byId == null) {
byId = new HashMap<String, LabelType>();
if (labelTypes != null) {
for (LabelType t : labelTypes) {
if (t.getId() != null) {
byId.put(t.getId(), t);
}
}
}
}
return byId;
}
@Override
public String toString() {
return labelTypes.toString();