@Test public void testCompareFirst() { assertEquals(0, new ExtensionComparator(true).compareFirst(new Path("/a.a", EnumSet.of(Path.Type.directory)), new Path("/b.b", EnumSet.of(Path.Type.directory)))); assertEquals(0, new ExtensionComparator(true).compareFirst(new Path("/a", EnumSet.of(Path.Type.file)), new Path("/b", EnumSet.of(Path.Type.file)))); assertEquals(1, new ExtensionComparator(true).compareFirst(new Path("/a.txt", EnumSet.of(Path.Type.file)), new Path("/b", EnumSet.of(Path.Type.file)))); assertEquals(0, new ExtensionComparator(true).compareFirst(new Path("/a.txt", EnumSet.of(Path.Type.file)), new Path("/b.txt", EnumSet.of(Path.Type.file)))); assertEquals(-1, new ExtensionComparator(true).compareFirst(new Path("/a", EnumSet.of(Path.Type.file)), new Path("/b.txt", EnumSet.of(Path.Type.file)))); }
@Override protected int compareFirst(final Path p1, final Path p2) { if(p1.isDirectory() && p2.isDirectory()) { return 0; } if(p1.isFile() && p2.isFile()) { if(StringUtils.isBlank(p1.getExtension()) && StringUtils.isBlank(p2.getExtension())) { return 0; } if(StringUtils.isBlank(p1.getExtension())) { return -1; } if(StringUtils.isBlank(p2.getExtension())) { return 1; } if(ascending) { return impl.compare(p1.getExtension(), p2.getExtension()); } return -impl.compare(p1.getExtension(), p2.getExtension()); } if(p1.isFile()) { return ascending ? 1 : -1; } return ascending ? -1 : 1; }
ExtensionComparator extends BrowserComparator { @Override protected int compareFirst(final Path p1, final Path p2) { if(p1.isDirectory() && p2.isDirectory()) { return 0; } if(p1.isFile() && p2.isFile()) { if(StringUtils.isBlank(p1.getExtension()) && StringUtils.isBlank(p2.getExtension())) { return 0; } if(StringUtils.isBlank(p1.getExtension())) { return -1; } if(StringUtils.isBlank(p2.getExtension())) { return 1; } if(ascending) { return impl.compare(p1.getExtension(), p2.getExtension()); } return -impl.compare(p1.getExtension(), p2.getExtension()); } if(p1.isFile()) { return ascending ? 1 : -1; } return ascending ? -1 : 1; } }
ExtensionComparator extends BrowserComparator { @Override protected int compareFirst(final Path p1, final Path p2) { if(p1.isDirectory() && p2.isDirectory()) { return 0; } if(p1.isFile() && p2.isFile()) { if(StringUtils.isBlank(p1.getExtension()) && StringUtils.isBlank(p2.getExtension())) { return 0; } if(StringUtils.isBlank(p1.getExtension())) { return -1; } if(StringUtils.isBlank(p2.getExtension())) { return 1; } if(ascending) { return impl.compare(p1.getExtension(), p2.getExtension()); } return -impl.compare(p1.getExtension(), p2.getExtension()); } if(p1.isFile()) { return ascending ? 1 : -1; } return ascending ? -1 : 1; } ExtensionComparator(boolean ascending); }
ExtensionComparator extends BrowserComparator { @Override protected int compareFirst(final Path p1, final Path p2) { if(p1.isDirectory() && p2.isDirectory()) { return 0; } if(p1.isFile() && p2.isFile()) { if(StringUtils.isBlank(p1.getExtension()) && StringUtils.isBlank(p2.getExtension())) { return 0; } if(StringUtils.isBlank(p1.getExtension())) { return -1; } if(StringUtils.isBlank(p2.getExtension())) { return 1; } if(ascending) { return impl.compare(p1.getExtension(), p2.getExtension()); } return -impl.compare(p1.getExtension(), p2.getExtension()); } if(p1.isFile()) { return ascending ? 1 : -1; } return ascending ? -1 : 1; } ExtensionComparator(boolean ascending);  }
ExtensionComparator extends BrowserComparator { @Override protected int compareFirst(final Path p1, final Path p2) { if(p1.isDirectory() && p2.isDirectory()) { return 0; } if(p1.isFile() && p2.isFile()) { if(StringUtils.isBlank(p1.getExtension()) && StringUtils.isBlank(p2.getExtension())) { return 0; } if(StringUtils.isBlank(p1.getExtension())) { return -1; } if(StringUtils.isBlank(p2.getExtension())) { return 1; } if(ascending) { return impl.compare(p1.getExtension(), p2.getExtension()); } return -impl.compare(p1.getExtension(), p2.getExtension()); } if(p1.isFile()) { return ascending ? 1 : -1; } return ascending ? -1 : 1; } ExtensionComparator(boolean ascending);   }