VersionComparator implements Comparator<String>, Serializable { @Override public int compare(String version1, String version2) { Integer versionNumber1 = convertVersion(version1); Integer versionNumber2 = convertVersion(version2); if (versionNumber2 == null || versionNumber1 == null) { return 0; } return versionNumber1.compareTo(versionNumber2); }  @Override int compare(String version1, String version2);  }
@Test public void testVersionComparator() { VersionComparator vc = new VersionComparator(); assertEquals(0, vc.compare(null, "V 1.2.3")); assertEquals(0, vc.compare("V 1.2.3", "alpha")); assertEquals(0, vc.compare("V 1.2.3", "1.2.3")); assertEquals(1, vc.compare("1", "0.99")); assertEquals(-1, vc.compare("V 0.6.3", "0.6.4")); }