Remove unnecessary toLowerCase calls in AdminCreateProject

We are using equalsIgnoreCase here, we shouldn't need to convert
the string to lowercase first as the equality test will take care
of it for us.

While we are at it, make the code a bit easier to follow by adding
a blank line around each case, and clarifying the default and the
error cases a bit.

Signed-off-by: Shawn O. Pearce <sop@google.com>
CC: Ulrik Sjölin <ulrik.sjolin@gmail.com>
This commit is contained in:
Shawn O. Pearce
2009-08-12 12:26:15 -07:00
parent c05b9bc1e6
commit 6b0dce6fb4

View File

@@ -187,20 +187,21 @@ final class AdminCreateProject extends BaseCommand {
signedOffBy = stringToBoolean(useSignedOffBy, false);
if (submitTypeStr == null) {
submitTypeStr = "fast-forward-only";
}
if (submitTypeStr.toLowerCase().equalsIgnoreCase("fast-forward-only")) {
submitType = SubmitType.FAST_FORWARD_ONLY;
} else if (submitTypeStr.toLowerCase().equalsIgnoreCase("merge-if-necessary")) {
submitType = SubmitType.MERGE_IF_NECESSARY;
} else if (submitTypeStr.toLowerCase().equalsIgnoreCase("merge-always")) {
submitType = SubmitType.MERGE_ALWAYS;
} else if (submitTypeStr.toLowerCase().equalsIgnoreCase("cherry-pick")) {
submitType = SubmitType.CHERRY_PICK;
}
if (submitType == null) {
} else if (submitTypeStr.equalsIgnoreCase("fast-forward-only")) {
submitType = SubmitType.FAST_FORWARD_ONLY;
} else if (submitTypeStr.equalsIgnoreCase("merge-if-necessary")) {
submitType = SubmitType.MERGE_IF_NECESSARY;
} else if (submitTypeStr.equalsIgnoreCase("merge-always")) {
submitType = SubmitType.MERGE_ALWAYS;
} else if (submitTypeStr.equalsIgnoreCase("cherry-pick")) {
submitType = SubmitType.CHERRY_PICK;
} else {
throw new Failure(1, "Submit type must be either: fast-forward-only, "
+ "merge-if-necessary, merge-always or cherry-pick");
}