* @return a negative integer, zero, or a positive integer as the first
* argument is less than, equal to, or greater than the second.
* @throws ClassCastException if either resource is not an instance of FileResource.
*/
protected int resourceCompare(Resource foo, Resource bar) {
FileProvider fooFP = foo.as(FileProvider.class);
if (fooFP == null) {
throw new ClassCastException(foo.getClass()
+ " doesn't provide files");
}
File foofile = fooFP.getFile();
FileProvider barFP = bar.as(FileProvider.class);
if (barFP == null) {
throw new ClassCastException(bar.getClass()
+ " doesn't provide files");
}
File barfile = barFP.getFile();
return foofile.equals(barfile) ? 0
: FILE_UTILS.isLeadingPath(foofile, barfile) ? -1
: FILE_UTILS.normalize(foofile.getAbsolutePath()).compareTo(
FILE_UTILS.normalize(barfile.getAbsolutePath()));
}