LocalIndexDir implements Comparable<LocalIndexDir> { public String getJcrPath() { return indexMeta.indexPath; } LocalIndexDir(File dir); long size(); boolean isEmpty(); String getJcrPath(); String getFSPath(); @Override int compareTo(LocalIndexDir o); @Override String toString();  }
@Test public void comparison() throws Exception{ LocalIndexDir dir = new LocalIndexDir(createDirWithIndexMetaFile(new IndexMeta("/a/b", 100))); LocalIndexDir dir2 = new LocalIndexDir(createDirWithIndexMetaFile(new IndexMeta("/a/b/c", 200))); LocalIndexDir dir3 = new LocalIndexDir(createDirWithIndexMetaFile(new IndexMeta("/a", 300))); List<LocalIndexDir> dirs = Lists.newArrayList(); dirs.add(dir2); dirs.add(dir); dirs.add(dir3); Collections.sort(dirs, Collections.<LocalIndexDir>reverseOrder()); assertEquals("/a", dirs.get(0).getJcrPath()); assertEquals("/a/b/c", dirs.get(1).getJcrPath()); assertEquals("/a/b", dirs.get(2).getJcrPath()); }