RelativeFile { @NonNull public File getFile() { return mFile; } RelativeFile(@NonNull File base, @NonNull File file); @NonNull File getBase(); @NonNull File getFile(); @NonNull String getOsIndependentRelativePath(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static Function<RelativeFile, File> EXTRACT_BASE; static Function<RelativeFile, File> EXTRACT_FILE; static Function<RelativeFile, String> EXTRACT_PATH; }
@Test public void directoryFilter() throws Exception { mTemporaryFolder.newFile("foo"); mTemporaryFolder.newFolder("dir"); mTemporaryFolder.newFile("dir" + File.separator + "bar"); Set<RelativeFile> files = RelativeFiles.fromDirectory( mTemporaryFolder.getRoot(), relativeFile -> relativeFile.getFile().isDirectory()); assertEquals(1, files.size()); assertNotNull(findFile(files, "dir")); }