Skip to content

Commit 6c9f737

Browse files
committed
Javadoc
- Use Math.min().
1 parent 913cb00 commit 6c9f737

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class ThresholdingOutputStream extends OutputStream {
5252
private static final IOFunction<ThresholdingOutputStream, OutputStream> NOOP_OS_GETTER = os -> NullOutputStream.INSTANCE;
5353

5454
/**
55-
* The threshold at which the event will be triggered.
55+
* The number of bytes at which to trigger an event, a negative threshold is mapped to zero
5656
*/
5757
private final int threshold;
5858

@@ -79,24 +79,24 @@ public class ThresholdingOutputStream extends OutputStream {
7979
/**
8080
* Constructs an instance of this class which will trigger an event at the specified threshold.
8181
*
82-
* @param threshold The number of bytes at which to trigger an event.
82+
* @param threshold The number of bytes at which to trigger an event, a negative threshold is mapped to zero.
8383
*/
8484
public ThresholdingOutputStream(final int threshold) {
8585
this(threshold, IOConsumer.noop(), NOOP_OS_GETTER);
8686
}
8787

8888
/**
89-
* Constructs an instance of this class which will trigger an event at the specified threshold.
90-
* A negative threshold has no meaning and will be treated as 0
89+
* Constructs an instance of this class which will trigger an event at the specified threshold. A negative threshold has no meaning and will be treated as
90+
* 0.
9191
*
92-
* @param threshold The number of bytes at which to trigger an event.
93-
* @param thresholdConsumer Accepts reaching the threshold.
92+
* @param threshold The number of bytes at which to trigger an event, a negative threshold is mapped to zero.
93+
* @param thresholdConsumer Accepts reaching the threshold.
9494
* @param outputStreamGetter Gets the output stream.
9595
* @since 2.9.0
9696
*/
9797
public ThresholdingOutputStream(final int threshold, final IOConsumer<ThresholdingOutputStream> thresholdConsumer,
9898
final IOFunction<ThresholdingOutputStream, OutputStream> outputStreamGetter) {
99-
this.threshold = threshold < 0 ? 0 : threshold;
99+
this.threshold = Math.min(0, threshold);
100100
this.thresholdConsumer = thresholdConsumer == null ? IOConsumer.noop() : thresholdConsumer;
101101
this.outputStreamGetter = outputStreamGetter == null ? NOOP_OS_GETTER : outputStreamGetter;
102102
}
@@ -185,7 +185,7 @@ protected OutputStream getStream() throws IOException {
185185
/**
186186
* Gets the threshold, in bytes, at which an event will be triggered.
187187
*
188-
* @return The threshold point, in bytes.
188+
* @return The threshold point, in bytes, at which an event will be triggered, zero or greater.
189189
*/
190190
public int getThreshold() {
191191
return threshold;

0 commit comments

Comments
 (0)