@Test(expected = NoSuchElementException.class) public void directoryStreamOfDirectoryNoSuchElementTest() throws IOException { initRepository(); writeToCache("/dir/file.txt"); commitToMaster(); initGitFileSystem(); try(DirectoryStream<Path> ds = Files.newDirectoryStream(gfs.getPath("/dir"))) { Iterator<Path> dsIt = ds.iterator(); dsIt.next(); dsIt.next(); } }
@Nonnull @Override public Iterator<Path> iterator() { final Iterator<String> childrenIt = children.iterator(); return new Iterator<Path>() { private Path next; private boolean findNext() { while(childrenIt.hasNext()) { String child = childrenIt.next(); GitPath childPath = parent.resolve(child); try { if(filter == null || filter.accept(childPath)) { next = childPath; return true; } } catch(IOException ignore) { } } return false; } @Override public boolean hasNext() throws ClosedDirectoryStreamException { checkNotClosed(); return next != null || findNext(); } @Nonnull @Override public Path next() throws ClosedDirectoryStreamException, NoSuchElementException { checkNotClosed(); if(next != null || hasNext()) { Path ret = next; next = null; return ret; } throw new NoSuchElementException(); } @Override public void remove() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } }; }
GfsDirectoryStream implements DirectoryStream<Path> { @Nonnull @Override public Iterator<Path> iterator() { final Iterator<String> childrenIt = children.iterator(); return new Iterator<Path>() { private Path next; private boolean findNext() { while(childrenIt.hasNext()) { String child = childrenIt.next(); GitPath childPath = parent.resolve(child); try { if(filter == null || filter.accept(childPath)) { next = childPath; return true; } } catch(IOException ignore) { } } return false; } @Override public boolean hasNext() throws ClosedDirectoryStreamException { checkNotClosed(); return next != null || findNext(); } @Nonnull @Override public Path next() throws ClosedDirectoryStreamException, NoSuchElementException { checkNotClosed(); if(next != null || hasNext()) { Path ret = next; next = null; return ret; } throw new NoSuchElementException(); } @Override public void remove() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } }; } }
GfsDirectoryStream implements DirectoryStream<Path> { @Nonnull @Override public Iterator<Path> iterator() { final Iterator<String> childrenIt = children.iterator(); return new Iterator<Path>() { private Path next; private boolean findNext() { while(childrenIt.hasNext()) { String child = childrenIt.next(); GitPath childPath = parent.resolve(child); try { if(filter == null || filter.accept(childPath)) { next = childPath; return true; } } catch(IOException ignore) { } } return false; } @Override public boolean hasNext() throws ClosedDirectoryStreamException { checkNotClosed(); return next != null || findNext(); } @Nonnull @Override public Path next() throws ClosedDirectoryStreamException, NoSuchElementException { checkNotClosed(); if(next != null || hasNext()) { Path ret = next; next = null; return ret; } throw new NoSuchElementException(); } @Override public void remove() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } }; } GfsDirectoryStream(DirectoryNode dir, GitPath parent, @Nullable Filter<? super Path> filter); }
GfsDirectoryStream implements DirectoryStream<Path> { @Nonnull @Override public Iterator<Path> iterator() { final Iterator<String> childrenIt = children.iterator(); return new Iterator<Path>() { private Path next; private boolean findNext() { while(childrenIt.hasNext()) { String child = childrenIt.next(); GitPath childPath = parent.resolve(child); try { if(filter == null || filter.accept(childPath)) { next = childPath; return true; } } catch(IOException ignore) { } } return false; } @Override public boolean hasNext() throws ClosedDirectoryStreamException { checkNotClosed(); return next != null || findNext(); } @Nonnull @Override public Path next() throws ClosedDirectoryStreamException, NoSuchElementException { checkNotClosed(); if(next != null || hasNext()) { Path ret = next; next = null; return ret; } throw new NoSuchElementException(); } @Override public void remove() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } }; } GfsDirectoryStream(DirectoryNode dir, GitPath parent, @Nullable Filter<? super Path> filter); @Nonnull @Override Iterator<Path> iterator(); @Override void close(); }
GfsDirectoryStream implements DirectoryStream<Path> { @Nonnull @Override public Iterator<Path> iterator() { final Iterator<String> childrenIt = children.iterator(); return new Iterator<Path>() { private Path next; private boolean findNext() { while(childrenIt.hasNext()) { String child = childrenIt.next(); GitPath childPath = parent.resolve(child); try { if(filter == null || filter.accept(childPath)) { next = childPath; return true; } } catch(IOException ignore) { } } return false; } @Override public boolean hasNext() throws ClosedDirectoryStreamException { checkNotClosed(); return next != null || findNext(); } @Nonnull @Override public Path next() throws ClosedDirectoryStreamException, NoSuchElementException { checkNotClosed(); if(next != null || hasNext()) { Path ret = next; next = null; return ret; } throw new NoSuchElementException(); } @Override public void remove() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } }; } GfsDirectoryStream(DirectoryNode dir, GitPath parent, @Nullable Filter<? super Path> filter); @Nonnull @Override Iterator<Path> iterator(); @Override void close();  }