T
- The type of element returned by the iterator.public abstract class AbstractDirectoryStream<T> extends Object implements DirectoryStream<T>
DirectoryStream
interface to minimize the effort required to implement this interface.
It will take care of ending iteration when the stream is closed, and making sure that iterator()
is only called once.
Subclasses often only need to implement getNext()
. Optionally, if they need perform setup steps before iteration, they should override
setupIteration()
as well.
DirectoryStream.Filter<T>
Modifier | Constructor and Description |
---|---|
protected |
AbstractDirectoryStream(DirectoryStream.Filter<? super T> filter)
Creates a new
DirectoryStream . |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected abstract T |
getNext()
Returns the next element in iteration.
|
Iterator<T> |
iterator() |
protected void |
setupIteration()
Performs the necessary steps to setup iteration.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
protected AbstractDirectoryStream(DirectoryStream.Filter<? super T> filter)
DirectoryStream
.filter
- The optional filter to use.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
protected void setupIteration()
protected abstract T getNext() throws IOException
null
if there is no more next element.IOException
- If the next element could not be retrieved.Copyright © 2016–2023. All rights reserved.