LeanHit implements Comparable<LeanHit> { @Override public int compareTo(LeanHit o) { int res = (sortData != null) ? compareData(sortData, o.sortData) : Double.compare(o.relevance, relevance); return (res != 0) ? res : compareData(gid, o.gid); } LeanHit(byte [] gid, int partId, int distributionKey, double relevance);  LeanHit(byte [] gid, int partId, int distributionKey, double relevance, byte [] sortData); double getRelevance(); byte [] getGid(); byte [] getSortData(); boolean hasSortData(); int getPartId(); int getDistributionKey(); @Override int compareTo(LeanHit o);  }
@Test public void testOrderingByRelevance() { assertEquals(0, new LeanHit(gidA, 0, 0, 1).compareTo(new LeanHit(gidA, 0, 0, 1))); verifyTransitiveOrdering(new LeanHit(gidA, 0, 0, 1), new LeanHit(gidA, 0, 0, 0), new LeanHit(gidA, 0, 0, -1)); }
@Test public void testOrderingByGid() { assertEquals(0, new LeanHit(gidA, 0, 0, 1).compareTo(new LeanHit(gidA, 0, 0, 1))); verifyTransitiveOrdering(new LeanHit(gidA, 0, 0, 1), new LeanHit(gidB, 0, 0, 1), new LeanHit(gidC, 0, 0, 1)); }
@Test public void testOrderingBySortData() { assertEquals(0, new LeanHit(gidA, 0, 0, 0.0, gidA).compareTo(new LeanHit(gidA, 0, 0, 0.0, gidA))); verifyTransitiveOrdering(new LeanHit(gidA, 0, 0, 0.0, gidA), new LeanHit(gidA, 0, 0, 0.0, gidB), new LeanHit(gidA, 0, 0, 0.0, gidC)); }