@Test public void files() throws FileSystemException { CustomTypeSafeMatcher<Integer> matcher = new CustomTypeSafeMatcher<Integer>("Has at least one item") { @Override protected boolean matchesSafely(Integer item) { return item > 0; } }; MatcherAssert.assertThat( new FileSystemOfPath(RESOURCES).files(), Matchers.hasSize(matcher)); }
@Override public List<FileSystemPath> files() throws FileSystemException { try { List<FileSystemPath> files = new ArrayList<>(); Files.walkFileTree( path, new FileVisitor<Path>() { @Override public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, dir.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, file.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFileFailed(Path file, IOException exc) { return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) { return FileVisitResult.CONTINUE; } }); return files; } catch (IOException e) { throw new FileSystemException(e); } }
FileSystemOfPath implements FileSystem { @Override public List<FileSystemPath> files() throws FileSystemException { try { List<FileSystemPath> files = new ArrayList<>(); Files.walkFileTree( path, new FileVisitor<Path>() { @Override public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, dir.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, file.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFileFailed(Path file, IOException exc) { return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) { return FileVisitResult.CONTINUE; } }); return files; } catch (IOException e) { throw new FileSystemException(e); } } }
FileSystemOfPath implements FileSystem { @Override public List<FileSystemPath> files() throws FileSystemException { try { List<FileSystemPath> files = new ArrayList<>(); Files.walkFileTree( path, new FileVisitor<Path>() { @Override public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, dir.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, file.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFileFailed(Path file, IOException exc) { return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) { return FileVisitResult.CONTINUE; } }); return files; } catch (IOException e) { throw new FileSystemException(e); } } FileSystemOfPath(String path);   FileSystemOfPath(Path path); }
FileSystemOfPath implements FileSystem { @Override public List<FileSystemPath> files() throws FileSystemException { try { List<FileSystemPath> files = new ArrayList<>(); Files.walkFileTree( path, new FileVisitor<Path>() { @Override public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, dir.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, file.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFileFailed(Path file, IOException exc) { return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) { return FileVisitResult.CONTINUE; } }); return files; } catch (IOException e) { throw new FileSystemException(e); } } FileSystemOfPath(String path);   FileSystemOfPath(Path path); @Override List<FileSystemPath> files(); }
FileSystemOfPath implements FileSystem { @Override public List<FileSystemPath> files() throws FileSystemException { try { List<FileSystemPath> files = new ArrayList<>(); Files.walkFileTree( path, new FileVisitor<Path>() { @Override public FileVisitResult preVisitDirectory( Path dir, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, dir.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { files.add(new FileSystemPathRelative(path, file.toString())); return FileVisitResult.CONTINUE; } @Override public FileVisitResult visitFileFailed(Path file, IOException exc) { return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) { return FileVisitResult.CONTINUE; } }); return files; } catch (IOException e) { throw new FileSystemException(e); } } FileSystemOfPath(String path);   FileSystemOfPath(Path path); @Override List<FileSystemPath> files();  }