@Override
    protected int compareFirst(final Path p1, final Path p2) {
        // Version with no duplicate flag first
        final int duplicateComparison = Boolean.compare(!p1.attributes().isDuplicate(), !p2.attributes().isDuplicate());
        if(0 == duplicateComparison) {
            final int timestampComparison = super.compareFirst(p1, p2);
            if(0 == timestampComparison) {
                return StringUtils.compare(p1.attributes().getVersionId(), p2.attributes().getVersionId());
            }
            return timestampComparison;
        }
        return duplicateComparison;
    }
@Test
    public void testCompareFirst() {
        final Path p1 = new Path("/a", EnumSet.of(Path.Type.file));
        final Path p2 = new Path("/b", EnumSet.of(Path.Type.file));
        assertEquals(0, new VersionsComparator(true).compareFirst(p1, p2));
        p1.attributes().setDuplicate(true);
        assertEquals(-1, new VersionsComparator(true).compareFirst(p1, p2));
        final long ts = System.currentTimeMillis();
        p1.attributes().setModificationDate(ts);
        p2.attributes().setModificationDate(ts);
        assertEquals(-1, new VersionsComparator(true).compareFirst(p1, p2));
        p2.attributes().setModificationDate(ts - 1000);
        assertEquals(-1, new VersionsComparator(true).compareFirst(p1, p2));
        p1.attributes().setDuplicate(false);
        assertEquals(1, new VersionsComparator(true).compareFirst(p1, p2));
    }