@SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void testComparison() { compare("0.0.1", "0.0.2", 1); compare("0.0.2", "0.0.1", -1); compare("0.0.1-qual", "0.0.2", 1); compare("0.0.1.qual", "0.0.2", 1); compare("0.0.1.qual", "0.0.1.qual", 0); compare("0.0.1", "0.0.2-SNAPSHOT", -1); compare("0.0.1", "0.0.2.SNAPSHOT", -1); compare("0.0.0_SNAPSHOT", "0.0.1-SNAPSHOT-20141111114709760", 1); compare("0.0.0.SNAPSHOT", "0.0.1.SNAPSHOT-20141111114709760", 1); compare("2.0", "2.0.1-BUILD", 1); compare("2.0", "2.0.1.BUILD", 1); compare("2.0.1", "2.0-BUILD", -1); compare("2.0.1", "2.0.0.BUILD", -1); compare("2.0", "2.0-BUILD", -1); compare("2.1", "2.0-BUILD", -1); compare("2.1", "2.0.0.BUILD", -1); compare("1", "1.3", 1); compare("1-beta", "1-rc2", 1); compare("1-beta1", "1-beta10", 1); compare(STABLE, "10.5", -1); compare(STABLE, STABLE, 0); compare(STABLE, "10.6", 1); compare(STABLE, "10.5.8.1", 1); compare("10.5.8-rc2", "10.5.8-rc3", 1) ; compare("10.5.8-rc2", "10.5.8-rc1", -1); compare(STABLE, RC2, -1); CatalogItemComparator cmp = CatalogItemComparator.INSTANCE; assertTrue(cmp.compare(v(RC2), v("10.5.8-beta1")) == cmp.compare(v(RC2), v("10.5.8-beta3"))); }
@Override public int compare(CatalogItem<T, SpecT> o1, CatalogItem<T, SpecT> o2) { int symbolicNameComparison = o1.getSymbolicName().compareTo(o2.getSymbolicName()); if (symbolicNameComparison != 0) { return symbolicNameComparison; } else { return Collections.reverseOrder(VersionComparator.INSTANCE).compare(o1.getVersion(), o2.getVersion()); } }
CatalogItemComparator implements Comparator<CatalogItem<T, SpecT>> { @Override public int compare(CatalogItem<T, SpecT> o1, CatalogItem<T, SpecT> o2) { int symbolicNameComparison = o1.getSymbolicName().compareTo(o2.getSymbolicName()); if (symbolicNameComparison != 0) { return symbolicNameComparison; } else { return Collections.reverseOrder(VersionComparator.INSTANCE).compare(o1.getVersion(), o2.getVersion()); } } }
CatalogItemComparator implements Comparator<CatalogItem<T, SpecT>> { @Override public int compare(CatalogItem<T, SpecT> o1, CatalogItem<T, SpecT> o2) { int symbolicNameComparison = o1.getSymbolicName().compareTo(o2.getSymbolicName()); if (symbolicNameComparison != 0) { return symbolicNameComparison; } else { return Collections.reverseOrder(VersionComparator.INSTANCE).compare(o1.getVersion(), o2.getVersion()); } }  }
CatalogItemComparator implements Comparator<CatalogItem<T, SpecT>> { @Override public int compare(CatalogItem<T, SpecT> o1, CatalogItem<T, SpecT> o2) { int symbolicNameComparison = o1.getSymbolicName().compareTo(o2.getSymbolicName()); if (symbolicNameComparison != 0) { return symbolicNameComparison; } else { return Collections.reverseOrder(VersionComparator.INSTANCE).compare(o1.getVersion(), o2.getVersion()); } }  @SuppressWarnings("unchecked") static CatalogItemComparator<T,SpecT> getInstance(); @Override int compare(CatalogItem<T, SpecT> o1, CatalogItem<T, SpecT> o2); }
CatalogItemComparator implements Comparator<CatalogItem<T, SpecT>> { @Override public int compare(CatalogItem<T, SpecT> o1, CatalogItem<T, SpecT> o2) { int symbolicNameComparison = o1.getSymbolicName().compareTo(o2.getSymbolicName()); if (symbolicNameComparison != 0) { return symbolicNameComparison; } else { return Collections.reverseOrder(VersionComparator.INSTANCE).compare(o1.getVersion(), o2.getVersion()); } }  @SuppressWarnings("unchecked") static CatalogItemComparator<T,SpecT> getInstance(); @Override int compare(CatalogItem<T, SpecT> o1, CatalogItem<T, SpecT> o2); static final CatalogItemComparator<?, ?> INSTANCE; }