@Test public void testCompare() throws Exception { final Collection<String> sortedDescriptionsColl = new TreeSet<>(); for (final SnomedConcept concept : TEST_DATA) { sortedDescriptionsColl.add(concept.candidatePreferred); } final List<String> sortedDescriptions = new ArrayList<>(sortedDescriptionsColl); final List<SnomedConcept> sorted = new ArrayList<>(TEST_DATA); Collections.sort(sorted, new SnomedDescriptionComparator()); for (int i = 0; i < sorted.size(); i++) { assertEquals(sortedDescriptions.get(i), sorted.get(i).candidatePreferred); } }
public int compare(final SnomedConcept o1, final SnomedConcept o2) { if (o1 == o2) return 0; if (o1 != null) { if (o2 == null) return 1; else return o1.candidatePreferred.compareTo(o2.candidatePreferred); } return -1; }
SnomedDescriptionComparator implements Comparator<SnomedConcept> { public int compare(final SnomedConcept o1, final SnomedConcept o2) { if (o1 == o2) return 0; if (o1 != null) { if (o2 == null) return 1; else return o1.candidatePreferred.compareTo(o2.candidatePreferred); } return -1; } }
SnomedDescriptionComparator implements Comparator<SnomedConcept> { public int compare(final SnomedConcept o1, final SnomedConcept o2) { if (o1 == o2) return 0; if (o1 != null) { if (o2 == null) return 1; else return o1.candidatePreferred.compareTo(o2.candidatePreferred); } return -1; }  }
SnomedDescriptionComparator implements Comparator<SnomedConcept> { public int compare(final SnomedConcept o1, final SnomedConcept o2) { if (o1 == o2) return 0; if (o1 != null) { if (o2 == null) return 1; else return o1.candidatePreferred.compareTo(o2.candidatePreferred); } return -1; }  int compare(final SnomedConcept o1, final SnomedConcept o2); }
SnomedDescriptionComparator implements Comparator<SnomedConcept> { public int compare(final SnomedConcept o1, final SnomedConcept o2) { if (o1 == o2) return 0; if (o1 != null) { if (o2 == null) return 1; else return o1.candidatePreferred.compareTo(o2.candidatePreferred); } return -1; }  int compare(final SnomedConcept o1, final SnomedConcept o2);  }