Consolidate parsing and formatting for label votes

We currently support two styles of parsing, Label-Value and
Label=Value. Consolidate these into a single LabelVote class.
(Unfortunately for backwards-compatibility reasons we can't just
eliminate Label=Value in ReviewCommand.)

Change-Id: I9e5255b184d786226e6b11fe059001608c00673d
This commit is contained in:
Dave Borowitz
2013-12-10 18:26:52 -08:00
parent d6bbc3fcfb
commit 57ecf24c06
6 changed files with 244 additions and 42 deletions

View File

@@ -33,14 +33,18 @@ public class LabelType {
return new LabelType(name, values);
}
private static String checkName(String name) {
public static String checkName(String name) {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Empty label name");
}
if ("SUBM".equals(name)) {
throw new IllegalArgumentException(
"Reserved label name \"" + name + "\"");
}
for (int i = 0; i < name.length(); i++) {
char c = name.charAt(i);
if (!((c >= 'a' && c <= 'z') ||
if ((i == 0 && c == '-') ||
!((c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') ||
c == '-')) {