Recover from invalid flag value

This commit is contained in:
Jesse Boyd 2016-07-14 00:28:46 +10:00
parent a43430b722
commit ba568a3f60
2 changed files with 11 additions and 10 deletions

View File

@ -9,11 +9,7 @@ public class BooleanFlag extends Flag<Boolean> {
}
@Override public String valueToString(Object value) {
if (((boolean) value)) {
return "true";
} else {
return "false";
}
return value + "";
}
@Override public Boolean parseValue(String value) {

View File

@ -112,12 +112,17 @@ public class FlagManager {
StringBuilder flag_string = new StringBuilder();
int i = 0;
for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) {
try {
Flag flag = entry.getKey();
if (i != 0) {
flag_string.append(',');
}
flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´"));
i++;
} catch (Exception e) {
PS.debug("Failed to parse flag: " + entry.getKey() + "->" + entry.getValue());
e.printStackTrace();
}
}
return flag_string.toString();
}