@Test public void testComparison() { VersionComparator.INSTANCE.compare("B", "B-2"); assertVersionOrder("0", "1"); assertVersionOrder("0", "0.0", "0.9", "0.10", "0.10.0", "1"); assertVersionOrder("a", "b"); assertVersionOrder("1beta", "1", "2beta", "11beta"); assertVersionOrder("beta", "0", "1beta", "1-alpha", "1", "11beta", "11-alpha", "11"); assertVersionOrder("1.0-a", "1.0-b", "1.0"); assertVersionOrder("qualifier", "0qualifier", "0-qualifier", "0", "1-qualifier", "1"); assertVersionOrder("2.0.qualifier", "2.0", "2.0.0qualifier", "2.0.0-qualifier", "2.0.0.qualifier", "2.0.0"); assertVersionOrder("2.0.qualifier.0", "2.0", "2.0.0qualifier.0", "2.0.0-qualifier.0", "2.0.0.qualifier.0", "2.0.0", "2.0.0.0"); assertVersionOrder("0", "0.0", "0.1", "0.1.0", "0.1.1", "0.2", "0.2.1", "1", "1.0", "2"); assertVersionOrder("AA", "Aa", "aa"); assertVersionOrder("A", "B-2", "B-10", "B", "B0", "C", "b", "b1", "b9", "b10", "c", "0"); assertVersionOrder("0-qual", "0", "0.1", "1-qualC", "1_qualB", "1.qualA", "1", "1.0"); assertVersionOrder("0--qual", "0-qual", "0-qualB", "0-qualB2", "0-qualB10", "0-qualC", "0.qualA", "0", "0.1.qual", "0.1", "1"); assertVersionOrder( "0_SNAPSHOT", "0.1.SNAPSHOT", "1-SNAPSHOT-X-X", "1-SNAPSHOT-X", "1-SNAPSHOT-XX-X", "1-SNAPSHOT-XX", "1-SNAPSHOT", "1.0-SNAPSHOT-B", "1.0.SNAPSHOT-A", "1.2-SNAPSHOT", "1.10-SNAPSHOT", "qualifer", "0", "0.1", "1"); }
@Override public int compare(String v1, String v2) { if (v1==null && v2==null) return 0; if (v1==null) return -1; if (v2==null) return 1; boolean isV1Snapshot = v1.toUpperCase().contains(SNAPSHOT); boolean isV2Snapshot = v2.toUpperCase().contains(SNAPSHOT); if (isV1Snapshot == isV2Snapshot) { return compareDotSplitParts(splitOnDot(v1), splitOnDot(v2)); } else { return isV1Snapshot ? -1 : 1; } }
VersionComparator implements Comparator<String> { @Override public int compare(String v1, String v2) { if (v1==null && v2==null) return 0; if (v1==null) return -1; if (v2==null) return 1; boolean isV1Snapshot = v1.toUpperCase().contains(SNAPSHOT); boolean isV2Snapshot = v2.toUpperCase().contains(SNAPSHOT); if (isV1Snapshot == isV2Snapshot) { return compareDotSplitParts(splitOnDot(v1), splitOnDot(v2)); } else { return isV1Snapshot ? -1 : 1; } } }
VersionComparator implements Comparator<String> { @Override public int compare(String v1, String v2) { if (v1==null && v2==null) return 0; if (v1==null) return -1; if (v2==null) return 1; boolean isV1Snapshot = v1.toUpperCase().contains(SNAPSHOT); boolean isV2Snapshot = v2.toUpperCase().contains(SNAPSHOT); if (isV1Snapshot == isV2Snapshot) { return compareDotSplitParts(splitOnDot(v1), splitOnDot(v2)); } else { return isV1Snapshot ? -1 : 1; } }  }
VersionComparator implements Comparator<String> { @Override public int compare(String v1, String v2) { if (v1==null && v2==null) return 0; if (v1==null) return -1; if (v2==null) return 1; boolean isV1Snapshot = v1.toUpperCase().contains(SNAPSHOT); boolean isV2Snapshot = v2.toUpperCase().contains(SNAPSHOT); if (isV1Snapshot == isV2Snapshot) { return compareDotSplitParts(splitOnDot(v1), splitOnDot(v2)); } else { return isV1Snapshot ? -1 : 1; } }  static VersionComparator getInstance(); @Override int compare(String v1, String v2); }
VersionComparator implements Comparator<String> { @Override public int compare(String v1, String v2) { if (v1==null && v2==null) return 0; if (v1==null) return -1; if (v2==null) return 1; boolean isV1Snapshot = v1.toUpperCase().contains(SNAPSHOT); boolean isV2Snapshot = v2.toUpperCase().contains(SNAPSHOT); if (isV1Snapshot == isV2Snapshot) { return compareDotSplitParts(splitOnDot(v1), splitOnDot(v2)); } else { return isV1Snapshot ? -1 : 1; } }  static VersionComparator getInstance(); @Override int compare(String v1, String v2); static final VersionComparator INSTANCE; }