Clean up the formatting of the copied code in the update.

This commit is contained in:
graywolf336 2014-07-21 18:30:39 -05:00
parent a2d46b8e26
commit e4f32559b6

View File

@ -133,26 +133,23 @@ public class Update {
* The result is a positive integer if str1 is _numerically_ greater than str2. * The result is a positive integer if str1 is _numerically_ greater than str2.
* The result is zero if the strings are _numerically_ equal. * The result is zero if the strings are _numerically_ equal.
*/ */
private Integer versionCompare(String str1, String str2) private Integer versionCompare(String str1, String str2) {
{
String[] vals1 = str1.split("\\."); String[] vals1 = str1.split("\\.");
String[] vals2 = str2.split("\\."); String[] vals2 = str2.split("\\.");
int i = 0; int i = 0;
// set index to first non-equal ordinal or length of shortest version string // set index to first non-equal ordinal or length of shortest version string
while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
{
i++; i++;
} }
// compare first non-equal ordinal number // compare first non-equal ordinal number
if (i < vals1.length && i < vals2.length) if (i < vals1.length && i < vals2.length) {
{ return Integer.signum(Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])));
int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
return Integer.signum(diff);
} }
// the strings are equal or one string is a substring of the other // the strings are equal or one string is a substring of the other
// e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4" // e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4"
else else {
{
return Integer.signum(vals1.length - vals2.length); return Integer.signum(vals1.length - vals2.length);
} }
} }