@Test public void testCompareFirst() { assertEquals(0, new OwnerComparator(true).compareFirst(new Path("/a", EnumSet.of(Path.Type.file)), new Path("/b", EnumSet.of(Path.Type.file)))); final Path p = new Path("/a", EnumSet.of(Path.Type.file)); p.attributes().setOwner("o"); assertEquals(1, new OwnerComparator(true).compareFirst(p, new Path("/b", EnumSet.of(Path.Type.file)))); assertEquals(-1, new OwnerComparator(true).compareFirst(new Path("/b", EnumSet.of(Path.Type.file)), p)); }
@Override protected int compareFirst(final Path p1, final Path p2) { if(StringUtils.isBlank(p1.attributes().getOwner()) && StringUtils.isBlank(p2.attributes().getOwner())) { return 0; } if(StringUtils.isBlank(p1.attributes().getOwner())) { return -1; } if(StringUtils.isBlank(p2.attributes().getOwner())) { return 1; } if(ascending) { return p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); } return -p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); }
OwnerComparator extends BrowserComparator { @Override protected int compareFirst(final Path p1, final Path p2) { if(StringUtils.isBlank(p1.attributes().getOwner()) && StringUtils.isBlank(p2.attributes().getOwner())) { return 0; } if(StringUtils.isBlank(p1.attributes().getOwner())) { return -1; } if(StringUtils.isBlank(p2.attributes().getOwner())) { return 1; } if(ascending) { return p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); } return -p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); } }
OwnerComparator extends BrowserComparator { @Override protected int compareFirst(final Path p1, final Path p2) { if(StringUtils.isBlank(p1.attributes().getOwner()) && StringUtils.isBlank(p2.attributes().getOwner())) { return 0; } if(StringUtils.isBlank(p1.attributes().getOwner())) { return -1; } if(StringUtils.isBlank(p2.attributes().getOwner())) { return 1; } if(ascending) { return p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); } return -p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); } OwnerComparator(boolean ascending); }
OwnerComparator extends BrowserComparator { @Override protected int compareFirst(final Path p1, final Path p2) { if(StringUtils.isBlank(p1.attributes().getOwner()) && StringUtils.isBlank(p2.attributes().getOwner())) { return 0; } if(StringUtils.isBlank(p1.attributes().getOwner())) { return -1; } if(StringUtils.isBlank(p2.attributes().getOwner())) { return 1; } if(ascending) { return p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); } return -p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); } OwnerComparator(boolean ascending);  }
OwnerComparator extends BrowserComparator { @Override protected int compareFirst(final Path p1, final Path p2) { if(StringUtils.isBlank(p1.attributes().getOwner()) && StringUtils.isBlank(p2.attributes().getOwner())) { return 0; } if(StringUtils.isBlank(p1.attributes().getOwner())) { return -1; } if(StringUtils.isBlank(p2.attributes().getOwner())) { return 1; } if(ascending) { return p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); } return -p1.attributes().getOwner().compareToIgnoreCase(p2.attributes().getOwner()); } OwnerComparator(boolean ascending);   }