public static class Tailer.Builder extends AbstractStreamBuilder<Tailer,Tailer.Builder>
Tailer
with default values.
For example:
Tailer t = Tailer.builder()
.setPath(path)
.setCharset(StandardCharsets.UTF_8)
.setDelayDuration(Duration.ofSeconds(1))
.setExecutorService(Executors.newSingleThreadExecutor(Builder::newDaemonThread))
.setReOpen(false)
.setStartThread(true)
.setTailable(tailable)
.setTailerListener(tailerListener)
.setTailFromEnd(false)
.get();
Modifier and Type | Field and Description |
---|---|
private static java.time.Duration |
DEFAULT_DELAY_DURATION |
private java.time.Duration |
delayDuration |
private boolean |
end |
private java.util.concurrent.ExecutorService |
executorService |
private boolean |
reOpen |
private boolean |
startThread |
private Tailer.Tailable |
tailable |
private TailerListener |
tailerListener |
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
Tailer |
get()
Constructs a new instance.
|
private static java.lang.Thread |
newDaemonThread(java.lang.Runnable runnable)
Creates a new daemon thread.
|
Tailer.Builder |
setDelayDuration(java.time.Duration delayDuration)
Sets the delay duration.
|
Tailer.Builder |
setExecutorService(java.util.concurrent.ExecutorService executorService)
Sets the executor service to use when startThread is true.
|
protected Tailer.Builder |
setOrigin(AbstractOrigin<?,?> origin)
Sets the origin.
|
Tailer.Builder |
setReOpen(boolean reOpen)
Sets the re-open behavior.
|
Tailer.Builder |
setStartThread(boolean startThread)
Sets the daemon thread startup behavior.
|
Tailer.Builder |
setTailable(Tailer.Tailable tailable)
Sets the tailable.
|
Tailer.Builder |
setTailerListener(TailerListener tailerListener)
Sets the listener.
|
Tailer.Builder |
setTailFromEnd(boolean end)
Sets the tail start behavior.
|
getBufferSize, getBufferSizeDefault, getCharSequence, getCharset, getCharsetDefault, getInputStream, getOpenOptions, getOutputStream, getPath, getWriter, setBufferSize, setBufferSize, setBufferSizeChecker, setBufferSizeDefault, setBufferSizeMax, setCharset, setCharset, setCharsetDefault, setOpenOptions
checkOrigin, getOrigin, hasOrigin, newByteArrayOrigin, newCharSequenceOrigin, newFileOrigin, newFileOrigin, newInputStreamOrigin, newOutputStreamOrigin, newPathOrigin, newPathOrigin, newReaderOrigin, newURIOrigin, newWriterOrigin, setByteArray, setCharSequence, setFile, setFile, setInputStream, setOutputStream, setPath, setPath, setReader, setURI, setWriter
asThis
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
asSupplier
private static final java.time.Duration DEFAULT_DELAY_DURATION
private Tailer.Tailable tailable
private TailerListener tailerListener
private java.time.Duration delayDuration
private boolean end
private boolean reOpen
private boolean startThread
private java.util.concurrent.ExecutorService executorService
private static java.lang.Thread newDaemonThread(java.lang.Runnable runnable)
runnable
- the thread's runnable.public Tailer get()
This builder use the aspects tailable, Charset, TailerListener, delayDuration, end, reOpen, buffer size.
public Tailer.Builder setDelayDuration(java.time.Duration delayDuration)
delayDuration
- the delay between checks of the file for new content.public Tailer.Builder setExecutorService(java.util.concurrent.ExecutorService executorService)
executorService
- the executor service to use when startThread is true.protected Tailer.Builder setOrigin(AbstractOrigin<?,?> origin)
setOrigin
in class AbstractOriginSupplier<Tailer,Tailer.Builder>
origin
- the new origin.java.lang.UnsupportedOperationException
- if the origin cannot be converted to a Path.public Tailer.Builder setReOpen(boolean reOpen)
reOpen
- whether to close/reopen the file between chunkspublic Tailer.Builder setStartThread(boolean startThread)
startThread
- whether to create a daemon thread automatically.public Tailer.Builder setTailable(Tailer.Tailable tailable)
tailable
- the tailable.public Tailer.Builder setTailerListener(TailerListener tailerListener)
tailerListener
- the listener.public Tailer.Builder setTailFromEnd(boolean end)
end
- Set to true to tail from the end of the file, false to tail from the beginning of the file.