@Test public void testSmallerNonEqualLength() { Assert.assertEquals(-1, underTest.compare(new VersionString("2.4.0.0"), new VersionString("2.5.0.0-770"))); }
@Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); }
VersionComparator implements Comparator<Versioned>, Serializable { @Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); } }
VersionComparator implements Comparator<Versioned>, Serializable { @Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); }  }
VersionComparator implements Comparator<Versioned>, Serializable { @Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); }  @Override int compare(Versioned o1, Versioned o2); }
VersionComparator implements Comparator<Versioned>, Serializable { @Override public int compare(Versioned o1, Versioned o2) { String[] vals1 = o1.getVersion().split(VERSION_SPLITTER_REGEX); String[] vals2 = o2.getVersion().split(VERSION_SPLITTER_REGEX); int i = 0; while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) { i++; } if (i < vals1.length && i < vals2.length) { int diff = StringUtils.isNumeric(vals1[i]) && StringUtils.isNumeric(vals2[i]) ? Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i])) : getDiffByPreReleaseIdPrecedence(vals1[i], vals2[i]); return Integer.signum(diff); } return Integer.signum(vals2.length - vals1.length); }  @Override int compare(Versioned o1, Versioned o2);  }