@Override public int compare(DocumentMetadata o1, DocumentMetadata o2) { if (o1.getTitle().equals(o2.getTitle())) { return o1.compareTo(o2); } return o1.getTitle().compareTo(o2.getTitle()); }
@Override public int compareTo(DocumentMetadata o) { // don't use static comparators since we may get bounced back here if (getTitle().equals(o.getTitle()) == false) { return getTitle().compareTo(o.getTitle()); } if (getAuthor().equals(o.getAuthor()) == false) { return getAuthor().compareTo(o.getAuthor()); } if (getPubDate().equals(o.getPubDate()) == false) { return getPubDate().compareTo(o.getPubDate()); } return Integer.compare(hashCode(), o.hashCode()); // give up }