public static final class CapturingWriter.Config.Builder extends Object
capturing writer configurations
.Modifier and Type | Method and Description |
---|---|
CapturingWriter.Config |
build()
Creates a new
capturing writer configuration with the settings from this builder. |
CapturingWriter.Config.Builder |
onDone(Consumer<? super CapturingWriter> callback)
Sets a callback that will be triggered when reading from built capturing writers is done.
|
CapturingWriter.Config.Builder |
onError(BiConsumer<? super CapturingWriter,? super IOException> callback)
Sets a callback that will be triggered when an
IOException occurs while using built capturing writers. |
CapturingWriter.Config.Builder |
onLimitReached(Consumer<? super CapturingWriter> callback)
Sets a callback that will be triggered when built capturing writers hit their limit.
|
CapturingWriter.Config.Builder |
withExpectedCount(int expectedCount)
Sets the expected number of characters that can be written to the wrapped writer.
|
CapturingWriter.Config.Builder |
withLimit(int limit)
Sets the maximum number of characters to capture.
|
public CapturingWriter.Config.Builder withLimit(int limit)
Integer.MAX_VALUE
.limit
- The maximum number of characters to capture.IllegalArgumentException
- If the given limit is negative.public CapturingWriter.Config.Builder withExpectedCount(int expectedCount)
-1
.expectedCount
- The expected number of characters that can be written to the wrapped writer, or a negative number if not known.public CapturingWriter.Config.Builder onDone(Consumer<? super CapturingWriter> callback)
closed
or because it has been explicitly marked as done
.
A capturing writer will only trigger its callback once.callback
- The callback to set.NullPointerException
- If the given callback is null
.public CapturingWriter.Config.Builder onLimitReached(Consumer<? super CapturingWriter> callback)
callback
- The callback to set.NullPointerException
- If the given callback is null
.public CapturingWriter.Config.Builder onError(BiConsumer<? super CapturingWriter,? super IOException> callback)
IOException
occurs while using built capturing writers.
A capturing writer can trigger its error callback multiple times.callback
- The callback to set.NullPointerException
- If the given callback is null
.public CapturingWriter.Config build()
capturing writer configuration
with the settings from this builder.Copyright © 2020–2024. All rights reserved.