@Override
    public int compare(Path o1, Path o2) {
        final String c1 = PathNormalizer.name(o1.getAbsolute());
        final boolean c2 = PathNormalizer.name(o2.getAbsolute()).matches(pattern);
        if(c1.matches(pattern) && c2) {
            return 0;
        }
        if(c1.matches(pattern)) {
            return -1;
        }
        if(c2) {
            return 1;
        }
        return super.compare(o1, o2);
    }
@Test
    public void testCompare() {
        assertEquals(-1, new DownloadRegexPriorityComparator(".*\\.html").compare(
                new Path("f.html", EnumSet.of(Path.Type.file)), new Path("g.t", EnumSet.of(Path.Type.file))));
        assertEquals(1, new DownloadRegexPriorityComparator(".*\\.html").compare(
                new Path("f.htm", EnumSet.of(Path.Type.file)), new Path("g.html", EnumSet.of(Path.Type.file))));
        assertEquals(0, new DownloadRegexPriorityComparator(".*\\.html").compare(
                new Path("f.html", EnumSet.of(Path.Type.file)), new Path("g.html", EnumSet.of(Path.Type.file))));
    }