@Test public void testCompare() { assertEquals(-1, new PathPriorityComparator().compare( new Path("/t", EnumSet.of(Path.Type.directory)), new Path("/t", EnumSet.of(Path.Type.file)) )); assertEquals(1, new PathPriorityComparator().compare( new Path("/t", EnumSet.of(Path.Type.file)), new Path("/t", EnumSet.of(Path.Type.directory)) )); assertEquals(0, new PathPriorityComparator().compare( new Path("/t", EnumSet.of(Path.Type.directory)), new Path("/t", EnumSet.of(Path.Type.directory)) )); assertEquals(0, new PathPriorityComparator().compare( new Path("/t", EnumSet.of(Path.Type.file)), new Path("/t", EnumSet.of(Path.Type.file)) )); }
@Override public int compare(final Path o1, final Path o2) { if(o1.isDirectory() && o2.isDirectory()) { return 0; } if(o1.isFile() && o2.isFile()) { return 0; } if(o1.isDirectory()) { return -1; } if(o2.isDirectory()) { return 1; } return 0; }
PathPriorityComparator implements Comparator<Path> { @Override public int compare(final Path o1, final Path o2) { if(o1.isDirectory() && o2.isDirectory()) { return 0; } if(o1.isFile() && o2.isFile()) { return 0; } if(o1.isDirectory()) { return -1; } if(o2.isDirectory()) { return 1; } return 0; } }
PathPriorityComparator implements Comparator<Path> { @Override public int compare(final Path o1, final Path o2) { if(o1.isDirectory() && o2.isDirectory()) { return 0; } if(o1.isFile() && o2.isFile()) { return 0; } if(o1.isDirectory()) { return -1; } if(o2.isDirectory()) { return 1; } return 0; }  }
PathPriorityComparator implements Comparator<Path> { @Override public int compare(final Path o1, final Path o2) { if(o1.isDirectory() && o2.isDirectory()) { return 0; } if(o1.isFile() && o2.isFile()) { return 0; } if(o1.isDirectory()) { return -1; } if(o2.isDirectory()) { return 1; } return 0; }  @Override int compare(final Path o1, final Path o2); }
PathPriorityComparator implements Comparator<Path> { @Override public int compare(final Path o1, final Path o2) { if(o1.isDirectory() && o2.isDirectory()) { return 0; } if(o1.isFile() && o2.isFile()) { return 0; } if(o1.isDirectory()) { return -1; } if(o2.isDirectory()) { return 1; } return 0; }  @Override int compare(final Path o1, final Path o2);  }